home *** CD-ROM | disk | FTP | other *** search
- <code _E_USER_TDE_>
- -------------------
- -- This file contains code sections for customizing the
- -- element type class.
- -------------------
-
-
- <code E_NAME_DEFS>
- -----------------------------------------------------
- -- Define name used in customizing the element class
- -----------------------------------------------------
- <clear _MEMBER_TYPE_>
- <if ($KEY_ACCESS_COLLECTION$)>
- <define _MEMBER_TYPE_>$KEY_TYPE$\</define>
- <else>
- <define _MEMBER_TYPE_>IString\</define>
- </if>
- </code E_NAME_DEFS>
-
-
- <code E_CUSTOMIZATION>
- ----------------------------------------------------
- -- Application specific functions and data.
- ----------------------------------------------------
- public:
- //------------------------------------------------------------------------
- // Constructor to initialize the private memebers
- //------------------------------------------------------------------------
- $ELEMENT_CLASS$($_MEMBER_TYPE_$ name) :
- iName(name)
- {
- }
-
- //------------------------------------------------------------------------
- // Overload the output operator to print out the contents of the
- // collection. The following is an example of printing out the
- // name member function of the $ELEMENT_CLASS$.
- //------------------------------------------------------------------------
- friend
- ostream& operator<< (ostream& os, $ELEMENT_CLASS$ const& a$ELEMENT_CLASS$)
- {
- return os << a$ELEMENT_CLASS$.iName;
- }
-
- //------------------------------------------------------------------------
- // Define access function to the private members of the class
- //------------------------------------------------------------------------
- $_MEMBER_TYPE_$ const& name() const
- {
- return iName;
- }
- <if ($KEY_ACCESS_COLLECTION$)>
-
- //------------------------------------------------------------------------
- // Obtain the key from a given element.
- //------------------------------------------------------------------------
- $KEY_TYPE$ const& getKey() const
- {
- // The member iName is of type $KEY_TYPE$ in this example.
- return iName;
- }
- </if>
-
- private:
- //------------------------------------------------------------------------
- // Private members of the element type.
- //------------------------------------------------------------------------
- $_MEMBER_TYPE_$ iName;
- </code E_CUSTOMIZATION>
-
-
-
- <code E_DEF_CONSTR_BODY>
- -------------------------------------------------------
- -- Default constructor implementation for element type
- -------------------------------------------------------
- -- $ELEMENT_CLASS$()
- {
- }
- </code E_DEF_CONSTR_BODY>
-
-
- <code E_COPY_CONSTR_BODY>
- ------------------------------------------------------
- -- Copy constructor implementation for element type
- ------------------------------------------------------
- -- $ELEMENT_CLASS$($ELEMENT_CLASS$ const& a$ELEMENT_CLASS$)
- : iName(a$ELEMENT_CLASS$.iName)
- {
- }
- </code E_COPY_CONSTR_BODY>
-
-
- <code E_DEF_DESTR_BODY>
- -------------------------------------------------------
- -- Default destructor implementation for element type. NOT USED NOW.
- -------------------------------------------------------
- </code E_DEF_DESTR_BODY>
-
-
- <code E_ASSIGN_BODY>
- --------------------------------------------------------
- -- Assignment operator implementation for element type.
- --------------------------------------------------------
- -- $ELEMENT_CLASS$& operator = ($ELEMENT_CLASS$ const& a$ELEMENT_CLASS$)
- {
- iName = a$ELEMENT_CLASS$.iName;
- return *this;
- }
- </code E_ASSIGN_BODY>
-
-
- <code E_EQUAL_BODY>
- -------------------------------------------------------
- -- Equality operator implementation for element type
- -------------------------------------------------------
- -- IBoolean operator== ($ELEMENT_CLASS$ const& a$ELEMENT_CLASS$) const
- {
- return (iName == a$ELEMENT_CLASS$.iName);
- }
- </code E_EQUAL_BODY>
-
-
- <code E_ORDER_BODY>
- ---------------------------------------------------------
- -- Ordering operator implementation for element type
- ---------------------------------------------------------
- -- IBoolean operator< ($ELEMENT_CLASS$ const& a$ELEMENT_CLASS$) const
- {
- return (iName < a$ELEMENT_CLASS$.iName);
- }
- </code E_ORDER_BODY>
-
-
-
- <code E_KEY_BODY_1>
- ----------------------------------------------------------
- -- key() function implementation for user-defined element
- ----------------------------------------------------------
- -- inline $KEY_TYPE$ const& key($ELEMENT_TYPE$ const& t)
- {
- // This function must call a member function that returns the key. In
- // this case the function is named get_key().
- // You can change always change it to call a different function.
- <if ($ELEMENT_PTR$)>
- return t->getKey();
- <else>
- return t.getKey();
- </if>
- }
- </code E_KEY_BODY_1>
-
-
- <code E_KEY_BODY_2>
- ----------------------------------------------------------
- -- key() function implementation for predefined element
- -- when the element type and key type are the same.
- ----------------------------------------------------------
- -- inline $KEY_TYPE$ const& key($ELEMENT_TYPE$ const& t)
- {
- // You should compute a key value from the $ELEMENT_TYPE$.
- // We will return a default here.
- return t;
- }
- </code E_KEY_BODY_2>
-
-
- <code E_KEY_BODY_3>
- ----------------------------------------------------------
- -- key() function implementation for predefined element
- -- when the element type and the key type are different.
- ----------------------------------------------------------
- -- inline $KEY_TYPE$ const& key($ELEMENT_TYPE$ const& t)
- {
- // We do not know how to return a default since $ELEMENT_CLASS$
- // is different from $KEY_CLASS$. You must supply a conversion here.
- }
- </code E_KEY_BODY_3>
-
-
- <code E_KEQUAL_BODY>
- ----------------------------------------------------------
- -- Key equality test for predefined element types
- ----------------------------------------------------------
- -- IBoolean equal ($KEY_TYPE$ const& e1, $KEY_TYPE$ const& e2)
- {
- return e1 == e2;
- }
- </code E_KEQUAL_BODY>
-
- <code HASH_BODY>
- ----------------------------------------------------------------
- -- Hash function implementation
- ----------------------------------------------------------------
- -- inline unsigned long hash($ELEMENT_TYPE$ const& a$ELEMENT_CLASS$, unsigned long hashInput)
- {
- <if ($ELEMENT_PTR$)>
- return hash((const char*)a$ELEMENT_CLASS$->name(), hashInput);
- <else>
- return hash((const char*)a$ELEMENT_CLASS$.name(), hashInput);
- </if>
- }
- </code HASH_BODY>
-
-
- </code _E_USER_TDE_>