home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / macros / e_user.tde < prev    next >
Encoding:
Text File  |  1996-02-22  |  6.6 KB  |  207 lines

  1. <code _E_USER_TDE_>
  2. -------------------
  3. -- This file contains code sections for customizing the
  4. -- element type class.
  5. -------------------
  6.  
  7.  
  8. <code E_NAME_DEFS>
  9. -----------------------------------------------------
  10. -- Define name used in customizing the element class
  11. -----------------------------------------------------
  12. <clear _MEMBER_TYPE_>
  13. <if ($KEY_ACCESS_COLLECTION$)>
  14. <define _MEMBER_TYPE_>$KEY_TYPE$\</define>
  15. <else>
  16. <define _MEMBER_TYPE_>IString\</define>
  17. </if>
  18. </code E_NAME_DEFS>
  19.  
  20.  
  21. <code E_CUSTOMIZATION>
  22. ----------------------------------------------------
  23. -- Application specific functions and data.
  24. ----------------------------------------------------
  25. public:
  26.      //------------------------------------------------------------------------
  27.      // Constructor to initialize the private memebers
  28.      //------------------------------------------------------------------------
  29.      $ELEMENT_CLASS$($_MEMBER_TYPE_$ name) :
  30.           iName(name)
  31.      {
  32.      }
  33.  
  34.      //------------------------------------------------------------------------
  35.      // Overload the output operator to print out the contents of the
  36.      // collection. The following is an example of printing out the
  37.      // name member function of the $ELEMENT_CLASS$.
  38.      //------------------------------------------------------------------------
  39.      friend
  40.      ostream& operator<< (ostream& os, $ELEMENT_CLASS$ const& a$ELEMENT_CLASS$)
  41.      {
  42.        return os << a$ELEMENT_CLASS$.iName;
  43.      }
  44.  
  45.      //------------------------------------------------------------------------
  46.      // Define access function to the private members of the class
  47.      //------------------------------------------------------------------------
  48.      $_MEMBER_TYPE_$ const& name() const
  49.      {
  50.         return iName;
  51.      }
  52. <if ($KEY_ACCESS_COLLECTION$)>
  53.  
  54.      //------------------------------------------------------------------------
  55.      // Obtain the key from a given element.
  56.      //------------------------------------------------------------------------
  57.      $KEY_TYPE$ const& getKey() const
  58.      {
  59.         // The member iName is of type $KEY_TYPE$ in this example.
  60.         return iName;
  61.      }
  62. </if>
  63.  
  64. private:
  65.      //------------------------------------------------------------------------
  66.      // Private members of the element type.
  67.      //------------------------------------------------------------------------
  68.      $_MEMBER_TYPE_$ iName;
  69. </code E_CUSTOMIZATION>
  70.  
  71.  
  72.  
  73. <code E_DEF_CONSTR_BODY>
  74. -------------------------------------------------------
  75. -- Default constructor implementation for element type
  76. -------------------------------------------------------
  77. --   $ELEMENT_CLASS$()
  78.      {
  79.      }
  80. </code E_DEF_CONSTR_BODY>
  81.  
  82.  
  83. <code E_COPY_CONSTR_BODY>
  84. ------------------------------------------------------
  85. -- Copy constructor implementation for element type
  86. ------------------------------------------------------
  87. --   $ELEMENT_CLASS$($ELEMENT_CLASS$ const& a$ELEMENT_CLASS$)
  88.         : iName(a$ELEMENT_CLASS$.iName)
  89.      {
  90.      }
  91. </code E_COPY_CONSTR_BODY>
  92.  
  93.  
  94. <code E_DEF_DESTR_BODY>
  95. -------------------------------------------------------
  96. -- Default destructor implementation for element type.  NOT USED NOW.
  97. -------------------------------------------------------
  98. </code E_DEF_DESTR_BODY>
  99.  
  100.  
  101. <code E_ASSIGN_BODY>
  102. --------------------------------------------------------
  103. -- Assignment operator implementation for element type.
  104. --------------------------------------------------------
  105. --   $ELEMENT_CLASS$& operator = ($ELEMENT_CLASS$ const& a$ELEMENT_CLASS$)
  106.      {
  107.         iName = a$ELEMENT_CLASS$.iName;
  108.         return *this;
  109.      }
  110. </code E_ASSIGN_BODY>
  111.  
  112.  
  113. <code E_EQUAL_BODY>
  114. -------------------------------------------------------
  115. -- Equality operator implementation for element type
  116. -------------------------------------------------------
  117. --   IBoolean operator== ($ELEMENT_CLASS$ const& a$ELEMENT_CLASS$) const
  118.      {
  119.         return (iName == a$ELEMENT_CLASS$.iName);
  120.      }
  121. </code E_EQUAL_BODY>
  122.  
  123.  
  124. <code E_ORDER_BODY>
  125. ---------------------------------------------------------
  126. -- Ordering operator implementation for element type
  127. ---------------------------------------------------------
  128. --   IBoolean operator< ($ELEMENT_CLASS$ const& a$ELEMENT_CLASS$) const
  129.      {
  130.         return (iName < a$ELEMENT_CLASS$.iName);
  131.      }
  132. </code E_ORDER_BODY>
  133.  
  134.  
  135.  
  136. <code E_KEY_BODY_1>
  137. ----------------------------------------------------------
  138. -- key() function implementation for user-defined element
  139. ----------------------------------------------------------
  140. -- inline $KEY_TYPE$ const& key($ELEMENT_TYPE$ const& t)
  141. {
  142. // This function must call a member function that returns the key. In
  143. // this case the function is named get_key().
  144. // You can change always change it to call a different function.
  145. <if ($ELEMENT_PTR$)>
  146.    return t->getKey();
  147. <else>
  148.    return t.getKey();
  149. </if>
  150. }
  151. </code E_KEY_BODY_1>
  152.  
  153.  
  154. <code E_KEY_BODY_2>
  155. ----------------------------------------------------------
  156. -- key() function implementation for predefined element
  157. -- when the element type and key type are the same.
  158. ----------------------------------------------------------
  159. -- inline $KEY_TYPE$ const& key($ELEMENT_TYPE$ const& t)
  160. {
  161.    // You should compute a key value from the $ELEMENT_TYPE$.
  162.    // We will return a default here.
  163.    return t;
  164. }
  165. </code E_KEY_BODY_2>
  166.  
  167.  
  168. <code E_KEY_BODY_3>
  169. ----------------------------------------------------------
  170. -- key() function implementation for predefined element
  171. -- when the element type and the key type are different.
  172. ----------------------------------------------------------
  173. -- inline $KEY_TYPE$ const& key($ELEMENT_TYPE$ const& t)
  174. {
  175.    // We do not know how to return a default since $ELEMENT_CLASS$
  176.    // is different from $KEY_CLASS$. You must supply a conversion here.
  177. }
  178. </code E_KEY_BODY_3>
  179.  
  180.  
  181. <code E_KEQUAL_BODY>
  182. ----------------------------------------------------------
  183. -- Key equality test for predefined element types
  184. ----------------------------------------------------------
  185. -- IBoolean equal ($KEY_TYPE$ const& e1, $KEY_TYPE$ const& e2)
  186. {
  187.    return e1 == e2;
  188. }
  189. </code E_KEQUAL_BODY>
  190.  
  191. <code HASH_BODY>
  192. ----------------------------------------------------------------
  193. -- Hash function implementation
  194. ----------------------------------------------------------------
  195. -- inline unsigned long hash($ELEMENT_TYPE$ const& a$ELEMENT_CLASS$, unsigned long hashInput)
  196. {
  197. <if ($ELEMENT_PTR$)>
  198.    return hash((const char*)a$ELEMENT_CLASS$->name(), hashInput);
  199. <else>
  200.    return hash((const char*)a$ELEMENT_CLASS$.name(), hashInput);
  201. </if>
  202. }
  203. </code HASH_BODY>
  204.  
  205.  
  206. </code _E_USER_TDE_>
  207.