Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 7, 2010, 12:58:52 AM (14 years ago)
Author:
landauf
Message:

enhanced documentation of some core classes and added examples

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/doc/src/libraries/core/SubclassIdentifier.h

    r7363 r7372  
    3232    @brief Definition of SubclassIdentifier.
    3333
     34    @anchor SubclassIdentifierExample
     35
    3436    SubclassIdentifier is a separated class, acting like an Identifier, but has a given class.
    3537    You can only assign Identifiers of exactly the given class or of a derivative to a SubclassIdentifier.
     38
     39    Example:
     40
     41    You can assign an Identifier either through the constructor or by using the assignment @c operator=:
     42    @code
     43    SubclassIdentifier<BaseClass> identifier = Class(SubClass);
     44    @endcode
     45
     46    The @c operator-> is overloaded an returns the assigned Identifier. That way you can just call
     47    functions of the assigned Identifier by using @c ->function():
     48    @code
     49    SubclassIdentifier<BaseClass> identifier = Class(SubClass);
     50    identifier->getName();      // returns "SubClass"
     51    @endcode
     52
     53    There are two possibilities to create an object out of a SubclassIdentifier: Either you just use
     54    the @c fabricate() function of the assigned Identifier through the overloaded @c operator->, which
     55    returns a @c BaseObject* pointer, or you use the function of SubclassIdentifier, this time by using
     56    @c operator., which returns a @c BaseClass* pointer (@a BaseClass is the baseclass specified by the
     57    template argument):
     58    @code
     59    identifier->fabricate();    // calls Identifier::fabricate(), creates a SubClass, returns a BaseObject* pointer
     60
     61    identifier.fabricate();     // calls SubclassIdentifier::fabricate(), creates a SubClass, returns a BaseClass* pointer
     62    @endcode
    3663*/
    3764
     
    5077    // ###   SubclassIdentifier    ###
    5178    // ###############################
    52     //! The SubclassIdentifier acts almost like an Identifier, but has some prerequisites.
    5379    /**
     80        @brief The SubclassIdentifier acts almost like an Identifier, but has some prerequisites.
     81
    5482        You can only assign an Identifier that belongs to a class T (or derived) to a SubclassIdentifier<T>.
    55         If you assign something else, the program aborts.
    56         Because we know the minimum type, a dynamic_cast is done, which makes it easier to create a new object.
     83        If you assign something else, the program prints an error.
     84
     85        Because we know the base-type, a @c dynamic_cast is done, which makes it easier to create a new object.
     86
     87        @see See @ref SubclassIdentifierExample "SubclassIdentifier.h" for some examples.
    5788    */
    5889    template <class T>
     
    6091    {
    6192        public:
    62             /**
    63                 @brief Constructor: Automaticaly assigns the Identifier of the given class.
    64             */
     93            /// Constructor: Automaticaly assigns the Identifier of the given class.
    6594            SubclassIdentifier()
    6695            {
     
    6897            }
    6998
    70             /**
    71                 @brief Constructor: Assigns the given Identifier.
    72                 @param identifier The Identifier
    73             */
     99            /// Constructor: Assigns the given Identifier.
    74100            SubclassIdentifier(Identifier* identifier)
    75101            {
     
    77103            }
    78104
    79             /**
    80                 @brief Copyconstructor: Assigns the identifier of the other SubclassIdentifier.
    81                 @param identifier The other SublcassIdentifier
    82             */
     105            /// Copyconstructor: Assigns the identifier of another SubclassIdentifier.
    83106            template <class O>
    84107            SubclassIdentifier(const SubclassIdentifier<O>& identifier)
     
    114137            }
    115138
    116             /**
    117                 @brief Overloading of the = operator: assigns the identifier of the other SubclassIdentifier.
    118                 @param identifier The other SublcassIdentifier
    119             */
     139            /// Overloading of the = operator: assigns the identifier of another SubclassIdentifier.
    120140            template <class O>
    121141            SubclassIdentifier<T>& operator=(const SubclassIdentifier<O>& identifier)
     
    124144            }
    125145
    126             /**
    127                 @brief Overloading of the * operator: returns the assigned identifier.
    128             */
     146            /// Overloading of the * operator: returns the assigned identifier.
    129147            inline Identifier* operator*() const
    130148            {
     
    132150            }
    133151
    134             /**
    135                 @brief Overloading of the -> operator: returns the assigned identifier.
    136             */
     152            /// Overloading of the -> operator: returns the assigned identifier.
    137153            inline Identifier* operator->() const
    138154            {
     
    140156            }
    141157
    142             /**
    143                 @brief Returns the assigned identifier. This allows you to assign a SubclassIdentifier to a normal Identifier*.
    144             */
     158            /// Returns the assigned identifier. This allows you to assign a SubclassIdentifier to a normal Identifier*.
    145159            inline operator Identifier*() const
    146160            {
     
    148162            }
    149163
    150             /**
    151                 @brief Creates a new object of the type of the assigned Identifier and dynamic_casts it to the minimal type given by T.
    152                 @return The new object
    153             */
     164            /// Creates a new object of the type of the assigned Identifier and dynamic_casts it to the minimal type given by T.
    154165            T* fabricate(BaseObject* creator) const
    155166            {
     
    182193            }
    183194
    184             /** @brief Returns the assigned identifier. @return The identifier */
     195            /// Returns the assigned identifier.
    185196            inline Identifier* getIdentifier() const
    186197                { return this->identifier_; }
Note: See TracChangeset for help on using the changeset viewer.