Changeset 7401 for code/trunk/src/libraries/core/SubclassIdentifier.h
- Timestamp:
- Sep 11, 2010, 12:34:00 AM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/doc (added) merged: 7290-7292,7296-7300,7302-7304,7306-7312,7315-7318,7323,7325,7327,7331-7332,7334-7335,7345-7347,7352-7353,7356-7357,7361,7363-7367,7371-7375,7388
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/core/SubclassIdentifier.h
r7268 r7401 29 29 /** 30 30 @file 31 @ingroup Class Identifier 31 32 @brief Definition of SubclassIdentifier. 33 34 @anchor SubclassIdentifierExample 32 35 33 36 SubclassIdentifier is a separated class, acting like an Identifier, but has a given class. 34 37 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 35 63 */ 36 64 … … 49 77 // ### SubclassIdentifier ### 50 78 // ############################### 51 //! The SubclassIdentifier acts almost like an Identifier, but has some prerequisites.52 79 /** 80 @brief The SubclassIdentifier acts almost like an Identifier, but has some prerequisites. 81 53 82 You can only assign an Identifier that belongs to a class T (or derived) to a SubclassIdentifier<T>. 54 If you assign something else, the program aborts. 55 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. 56 88 */ 57 89 template <class T> … … 59 91 { 60 92 public: 61 /** 62 @brief Constructor: Automaticaly assigns the Identifier of the given class. 63 */ 93 /// Constructor: Automaticaly assigns the Identifier of the given class. 64 94 SubclassIdentifier() 65 95 { … … 67 97 } 68 98 69 /** 70 @brief Constructor: Assigns the given Identifier. 71 @param identifier The Identifier 72 */ 99 /// Constructor: Assigns the given Identifier. 73 100 SubclassIdentifier(Identifier* identifier) 74 101 { … … 76 103 } 77 104 78 /** 79 @brief Copyconstructor: Assigns the identifier of the other SubclassIdentifier. 80 @param identifier The other SublcassIdentifier 81 */ 105 /// Copyconstructor: Assigns the identifier of another SubclassIdentifier. 82 106 template <class O> 83 107 SubclassIdentifier(const SubclassIdentifier<O>& identifier) … … 113 137 } 114 138 115 /** 116 @brief Overloading of the = operator: assigns the identifier of the other SubclassIdentifier. 117 @param identifier The other SublcassIdentifier 118 */ 139 /// Overloading of the = operator: assigns the identifier of another SubclassIdentifier. 119 140 template <class O> 120 141 SubclassIdentifier<T>& operator=(const SubclassIdentifier<O>& identifier) … … 123 144 } 124 145 125 /** 126 @brief Overloading of the * operator: returns the assigned identifier. 127 */ 146 /// Overloading of the * operator: returns the assigned identifier. 128 147 inline Identifier* operator*() const 129 148 { … … 131 150 } 132 151 133 /** 134 @brief Overloading of the -> operator: returns the assigned identifier. 135 */ 152 /// Overloading of the -> operator: returns the assigned identifier. 136 153 inline Identifier* operator->() const 137 154 { … … 139 156 } 140 157 141 /** 142 @brief Returns the assigned identifier. This allows you to assign a SubclassIdentifier to a normal Identifier*. 143 */ 158 /// Returns the assigned identifier. This allows you to assign a SubclassIdentifier to a normal Identifier*. 144 159 inline operator Identifier*() const 145 160 { … … 147 162 } 148 163 149 /** 150 @brief Creates a new object of the type of the assigned Identifier and dynamic_casts it to the minimal type given by T. 151 @return The new object 152 */ 164 /// Creates a new object of the type of the assigned Identifier and dynamic_casts it to the minimal type given by T. 153 165 T* fabricate(BaseObject* creator) const 154 166 { … … 181 193 } 182 194 183 / ** @brief Returns the assigned identifier. @return The identifier */195 /// Returns the assigned identifier. 184 196 inline Identifier* getIdentifier() const 185 197 { return this->identifier_; }
Note: See TracChangeset
for help on using the changeset viewer.