Changeset View
Changeset View
Standalone View
Standalone View
language/duchain/types/abstracttype.h
Show First 20 Lines • Show All 64 Lines • ▼ Show 20 Line(s) | |||||
65 | * - Override equals(..), hash(). | 65 | * - Override equals(..), hash(). | ||
66 | * - The functions should _fully_ distinguish all types, | 66 | * - The functions should _fully_ distinguish all types, | ||
67 | * in regard to all stored information, and regarding their identity. | 67 | * in regard to all stored information, and regarding their identity. | ||
68 | * - This can be skipped if you're overriding a base-type which already incorporates | 68 | * - This can be skipped if you're overriding a base-type which already incorporates | ||
69 | * all of your own types status within its equals/hash functions (eg. you don't add own data). | 69 | * all of your own types status within its equals/hash functions (eg. you don't add own data). | ||
70 | * - Implement a copy-constructor in which you copy the data from the source using copyData<YourType>() | 70 | * - Implement a copy-constructor in which you copy the data from the source using copyData<YourType>() | ||
71 | * - Override the clone() function in which you use the copy-constructor to clone the type | 71 | * - Override the clone() function in which you use the copy-constructor to clone the type | ||
72 | * - Add an enumerator "Identity" that contains an arbitrary unique identity value of the type | 72 | * - Add an enumerator "Identity" that contains an arbitrary unique identity value of the type | ||
73 | * - Add a typedef "BaseType" that specifies the base type, which must be a type that also follows these rules | | |||
74 | * - Register your type in a source-file using REGISTER_TYPE(..), @see typeregister.h | 73 | * - Register your type in a source-file using REGISTER_TYPE(..), @see typeregister.h | ||
75 | * - Add a typedef "Data", that contains the actual data of the type using the mechanisms described in appendedlist.h. | 74 | * - Add a typedef "Data", that contains the actual data of the type using the mechanisms described in appendedlist.h. | ||
76 | * - That data type must follow the same inheritance chain as the type itself, so it must be based on BaseType::Data. | 75 | * That data type must follow the same inheritance chain as the type itself, so it must be based on the Data object | ||
77 | * @see AbstractTypeData | 76 | * of the base class. See AbstractTypeData. | ||
78 | * - Use createData<YourType>() to create the data-object in a constructor (which you then reach to the parent constructor) | 77 | * - Use createData<YourType>() to create the data-object in a constructor (which you then reach to the parent constructor) | ||
79 | * - Use TYPE_DECLARE_DATA(YourType) to declare the data access functions d_func and d_func_dynamic, | 78 | * - Use TYPE_DECLARE_DATA(YourType) to declare the data access functions d_func and d_func_dynamic, | ||
80 | * and then use d_func()->.. and d_func_dynamic()->.. to access your type data | 79 | * and then use d_func()->.. and d_func_dynamic()->.. to access your type data | ||
81 | * - Create a constructor that only takes a reference to the type data, and passes it to the parent type | 80 | * - Create a constructor that only takes a reference to the type data, and passes it to the parent type | ||
82 | * | 81 | * | ||
83 | * Every type can have only one other type as base-type, | 82 | * Every type can have only one other type as base-type, | ||
84 | * but it can have additional base-classes that are not a direct part of the type-system(@see IdentifiedType). | 83 | * but it can have additional base-classes that are not a direct part of the type-system(@see IdentifiedType). | ||
85 | * | 84 | * | ||
▲ Show 20 Lines • Show All 224 Lines • Show Last 20 Lines |