There are two situations where you need to derive from TAttribute directly and add your own member functions and data members:
- When the attribute data is so small that there is no advantage to sharing it.
- When the data inherently cannot be shared. An example of this type of attribute might be a logical end of file attribute: although there are many instances, nearly all the values end up different, so sharing would not actually occur.
Provide copy semantics for the newly defined class, regardless of whether you choose to derive from TAttribute or from the TSharedAttribute and TInternalAttribute pair.
Follow this process when you create a new class:
- Declare a default constructor, which is required by streaming.
- Declare a constructor with parameters to initialize the attribute data.
- Declare the usual copy constructor, destructor, and assignment operator.
- Declare the streaming operators.
- Optionally, override GetName and GetCategory to return the names you want. If you do not, GetName and GetCategory each use the class name.
- Override Hash and IsEqual to take into account your attribute's data.
- Declare any private variables that you use and public accessors for them.
[Contents]
[Previous]
[Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.
Generated with WebMaker