- Timestamp:
- Sep 7, 2010, 12:58:52 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/doc/src/libraries/core/SubclassIdentifier.h
r7363 r7372 32 32 @brief Definition of SubclassIdentifier. 33 33 34 @anchor SubclassIdentifierExample 35 34 36 SubclassIdentifier is a separated class, acting like an Identifier, but has a given class. 35 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 36 63 */ 37 64 … … 50 77 // ### SubclassIdentifier ### 51 78 // ############################### 52 //! The SubclassIdentifier acts almost like an Identifier, but has some prerequisites.53 79 /** 80 @brief The SubclassIdentifier acts almost like an Identifier, but has some prerequisites. 81 54 82 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. 57 88 */ 58 89 template <class T> … … 60 91 { 61 92 public: 62 /** 63 @brief Constructor: Automaticaly assigns the Identifier of the given class. 64 */ 93 /// Constructor: Automaticaly assigns the Identifier of the given class. 65 94 SubclassIdentifier() 66 95 { … … 68 97 } 69 98 70 /** 71 @brief Constructor: Assigns the given Identifier. 72 @param identifier The Identifier 73 */ 99 /// Constructor: Assigns the given Identifier. 74 100 SubclassIdentifier(Identifier* identifier) 75 101 { … … 77 103 } 78 104 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. 83 106 template <class O> 84 107 SubclassIdentifier(const SubclassIdentifier<O>& identifier) … … 114 137 } 115 138 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. 120 140 template <class O> 121 141 SubclassIdentifier<T>& operator=(const SubclassIdentifier<O>& identifier) … … 124 144 } 125 145 126 /** 127 @brief Overloading of the * operator: returns the assigned identifier. 128 */ 146 /// Overloading of the * operator: returns the assigned identifier. 129 147 inline Identifier* operator*() const 130 148 { … … 132 150 } 133 151 134 /** 135 @brief Overloading of the -> operator: returns the assigned identifier. 136 */ 152 /// Overloading of the -> operator: returns the assigned identifier. 137 153 inline Identifier* operator->() const 138 154 { … … 140 156 } 141 157 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*. 145 159 inline operator Identifier*() const 146 160 { … … 148 162 } 149 163 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. 154 165 T* fabricate(BaseObject* creator) const 155 166 { … … 182 193 } 183 194 184 / ** @brief Returns the assigned identifier. @return The identifier */195 /// Returns the assigned identifier. 185 196 inline Identifier* getIdentifier() const 186 197 { return this->identifier_; }
Note: See TracChangeset
for help on using the changeset viewer.