home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / iivss.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  8.5 KB  |  312 lines

  1. /**********************************************************************
  2. *                                                                     *
  3. *  IBM(R) VisualAge(TM) for C++ for Windows(R), Version 3.5           *
  4. *                                                                     *
  5. *  PID: 5622-880                                                      *
  6. *  - Licensed Material - Program-Property of IBM                      *
  7. *  (C) Copyright IBM Corp. 1991, 1995 - All Right Reserved.           *
  8. *                                                                     *
  9. *  US Government Users Restricted Rights - Use, duplication or        *
  10. *  disclosure restricted by GSA ADP Schedule Contract with IBM Corp.  *
  11. *                                                                     *
  12. *  VisualAge, and IBM are trademarks or registered trademarks of      *
  13. *  International Business Machines Corporation.                       *
  14. *  Windows is a registered trademark of Microsoft Corporation.        *
  15. *                                                                     *
  16. **********************************************************************/
  17.  
  18. #pragma info (nocls, nocnd, nocns, nocnv, noext, nognr, novft)
  19. #pragma pack (4)
  20.  
  21. // ---
  22. // IVSortedSetImpl
  23. // ---
  24.  
  25. // public members
  26.  
  27. template <class VInherited>
  28. IVSortedSetImpl <VInherited>::
  29. IVSortedSetImpl (Ops& ops, INumber numberOfElements)
  30. : VInherited (ops, numberOfElements)
  31. {
  32. }
  33.  
  34. template <class VInherited>
  35. IVSortedSetImpl <VInherited>::
  36. IVSortedSetImpl
  37.   (Ops& ops, IVSortedSetImpl <VInherited> const& collection)
  38. : VInherited (ops, collection)
  39. {
  40. }
  41.  
  42. template <class VInherited>
  43. IBoolean
  44. IVSortedSetImpl <VInherited>::
  45. Add (void const* element, ICursorImpl& cursor)
  46. { IBoolean isEnabled = IsEnabledForNotification ();
  47.   DisableNotification ();
  48.   IBoolean hasBeenAdded = VInherited::Add (element, cursor);
  49.   EnableNotification (isEnabled);
  50.   if (hasBeenAdded && HasObservers ()) {
  51.     NotifyOfAddAt (cursor);
  52.   }
  53.   return hasBeenAdded;
  54. }
  55.  
  56. template <class VInherited>
  57. void
  58. IVSortedSetImpl <VInherited>::
  59. AddAllFrom (IACollectionImpl const& collection)
  60. { IBoolean isEnabled = IsEnabledForNotification ();
  61.   DisableNotification ();
  62.   VInherited::AddAllFrom (collection);
  63.   EnableNotification (isEnabled);
  64.   if (HasObservers ()) {
  65.     NotifyOfModification ();
  66.   }
  67. }
  68.  
  69. template <class VInherited>
  70. void
  71. IVSortedSetImpl <VInherited>::
  72. AddAntivalence (IASortedSetImpl const& collection1,
  73.                 IASortedSetImpl const& collection2)
  74. { IBoolean isEnabled = IsEnabledForNotification ();
  75.   DisableNotification ();
  76.   VInherited::AddAntivalence (collection1, collection2);
  77.   EnableNotification (isEnabled);
  78.   if (HasObservers ()) {
  79.     NotifyOfModification ();
  80.   }
  81. }
  82.  
  83. template <class VInherited>
  84. void
  85. IVSortedSetImpl <VInherited>::
  86. AddDifference (IASortedSetImpl const& collection1,
  87.                IASortedSetImpl const& collection2)
  88. { IBoolean isEnabled = IsEnabledForNotification ();
  89.   DisableNotification ();
  90.   VInherited::AddDifference (collection1, collection2);
  91.   EnableNotification (isEnabled);
  92.   if (HasObservers ()) {
  93.     NotifyOfModification ();
  94.   }
  95. }
  96.  
  97. template <class VInherited>
  98. void
  99. IVSortedSetImpl <VInherited>::
  100. AddIntersection (IASortedSetImpl const& collection1,
  101.                IASortedSetImpl const& collection2)
  102. { IBoolean isEnabled = IsEnabledForNotification ();
  103.   DisableNotification ();
  104.   VInherited::AddIntersection (collection1, collection2);
  105.   EnableNotification (isEnabled);
  106.   if (HasObservers ()) {
  107.     NotifyOfModification ();
  108.   }
  109. }
  110.  
  111. template <class VInherited>
  112. void
  113. IVSortedSetImpl <VInherited>::
  114. AddUnion (IASortedSetImpl const& collection1,
  115.           IASortedSetImpl const& collection2)
  116. { IBoolean isEnabled = IsEnabledForNotification ();
  117.   DisableNotification ();
  118.   VInherited::AddUnion (collection1, collection2);
  119.   EnableNotification (isEnabled);
  120.   if (HasObservers ()) {
  121.     NotifyOfModification ();
  122.   }
  123. }
  124.  
  125. template <class VInherited>
  126. void
  127. IVSortedSetImpl <VInherited>::
  128. Antivalence (IASortedSetImpl const& collection)
  129. { IBoolean isEnabled = IsEnabledForNotification ();
  130.   DisableNotification ();
  131.   VInherited::Antivalence (collection);
  132.   EnableNotification (isEnabled);
  133.   if (HasObservers ()) {
  134.     NotifyOfModification ();
  135.   }
  136. }
  137. template <class VInherited>
  138. void
  139. IVSortedSetImpl <VInherited>::
  140. Copy (IACollectionImpl const& collection)
  141. { IBoolean isEnabled = IsEnabledForNotification ();
  142.   DisableNotification ();
  143.   VInherited::Copy (collection);
  144.   EnableNotification (isEnabled);
  145.   if (HasObservers ()) {
  146.     NotifyOfModification ();
  147.   }
  148. }
  149.  
  150. template <class VInherited>
  151. void
  152. IVSortedSetImpl <VInherited>::
  153. Difference (IASortedSetImpl const& collection)
  154. { IBoolean isEnabled = IsEnabledForNotification ();
  155.   DisableNotification ();
  156.   VInherited::Difference (collection);
  157.   EnableNotification (isEnabled);
  158.   if (HasObservers ()) {
  159.     NotifyOfModification ();
  160.   }
  161. }
  162.  
  163. template <class VInherited>
  164. void
  165. IVSortedSetImpl <VInherited>::
  166. Intersection (IASortedSetImpl const& collection)
  167. { IBoolean isEnabled = IsEnabledForNotification ();
  168.   DisableNotification ();
  169.   VInherited::Intersection (collection);
  170.   EnableNotification (isEnabled);
  171.   if (HasObservers ()) {
  172.     NotifyOfModification ();
  173.   }
  174. }
  175. template <class VInherited>
  176. IBoolean
  177. IVSortedSetImpl <VInherited>::
  178. LocateOrAdd (void const* element, ICursorImpl& cursor)
  179. { IBoolean isEnabled = IsEnabledForNotification ();
  180.   DisableNotification ();
  181.   IBoolean hasBeenLocated = VInherited::LocateOrAdd (element, cursor);
  182.   EnableNotification (isEnabled);
  183.   if (! hasBeenLocated && HasObservers ()) {
  184.     NotifyOfAddAt (cursor);
  185.   }
  186.   return hasBeenLocated;
  187. }
  188.  
  189. template <class VInherited>
  190. IBoolean
  191. IVSortedSetImpl <VInherited>::
  192. Remove (void const* element)
  193. { if (HasObservers () &&  Locate (element, CursorOf (*this))) {
  194.     NotifyOfRemoveAt (CursorOf (*this));
  195.   }
  196.   return VInherited::Remove (element);
  197. }
  198.  
  199. template <class VInherited>
  200. INumber
  201. IVSortedSetImpl <VInherited>::
  202. RemoveAll ()
  203. { INumber result = VInherited::RemoveAll ();
  204.   if (result > 0 && HasObservers ()) {
  205.     NotifyOfModification ();
  206.   }
  207.   return result;
  208. }
  209.  
  210. template <class VInherited>
  211. INumber
  212. IVSortedSetImpl <VInherited>::
  213. RemoveAll (IPredFunc predFunc, void* addArg)
  214. { INumber result = VInherited::RemoveAll (predFunc, addArg);
  215.   if (result > 0 && HasObservers ()) {
  216.     NotifyOfModification ();
  217.   }
  218.   return result;
  219. }
  220.  
  221. template <class VInherited>
  222. INumber
  223. IVSortedSetImpl <VInherited>::
  224. RemoveAllOccurrences (void const* element)
  225. { IBoolean isEnabled = IsEnabledForNotification ();
  226.   DisableNotification ();
  227.   INumber result = VInherited::RemoveAllOccurrences (element);
  228.   EnableNotification (isEnabled);
  229.   if (result > 0 && HasObservers ()) {
  230.     NotifyOfModification ();
  231.   }
  232.   return result;
  233. }
  234.  
  235. template <class VInherited>
  236. void
  237. IVSortedSetImpl <VInherited>::
  238. RemoveAt (ICursorImpl& cursor)
  239. { if (HasObservers ()) {
  240.     NotifyOfRemoveAt (cursor);
  241.   }
  242.   VInherited::RemoveAt (cursor);
  243. }
  244.  
  245. template <class VInherited>
  246. void
  247. IVSortedSetImpl <VInherited>::
  248. RemoveAtPosition (IPosition position)
  249. { if (HasObservers ()) {
  250.     SetToPosition (position, CursorOf (*this));
  251.     NotifyOfRemoveAt (CursorOf (*this));
  252.   }
  253.   VInherited::RemoveAtPosition (position);
  254. }
  255.  
  256. template <class VInherited>
  257. void
  258. IVSortedSetImpl <VInherited>::
  259. RemoveFirst ()
  260. { if (HasObservers ()) {
  261.     SetToFirst (CursorOf (*this));
  262.     NotifyOfRemoveAt (CursorOf (*this));
  263.   }
  264.   VInherited::RemoveFirst ();
  265. }
  266.  
  267. template <class VInherited>
  268. void
  269. IVSortedSetImpl <VInherited>::
  270. RemoveLast ()
  271. { if (HasObservers ()) {
  272.     SetToLast (CursorOf (*this));
  273.     NotifyOfRemoveAt (CursorOf (*this));
  274.   }
  275.   VInherited::RemoveLast ();
  276. }
  277.  
  278. template <class VInherited>
  279. void
  280. IVSortedSetImpl <VInherited>::
  281. ReplaceAt (ICursorImpl const& cursor, void const* element)
  282. { if (HasObservers ()) {
  283. #if defined (ICLCC_COMPAT_IVB)
  284.     NotifyOfRemoveAt (cursor); // to be removed in a future release
  285. #else
  286.     NotifyOfReplaceAt (cursor, element);
  287. #endif
  288.   }
  289.   VInherited::ReplaceAt (cursor, element);
  290. #if defined (ICLCC_COMPAT_IVB)
  291.   if (HasObservers ()) {
  292.     NotifyOfAddAt (cursor); // to be removed in a future release
  293.   }
  294. #endif
  295. }
  296.  
  297. template <class VInherited>
  298. void
  299. IVSortedSetImpl <VInherited>::
  300. Union (IASortedSetImpl const& collection)
  301. { IBoolean isEnabled = IsEnabledForNotification ();
  302.   DisableNotification ();
  303.   VInherited::Union (collection);
  304.   EnableNotification (isEnabled);
  305.   if (HasObservers ()) {
  306.     NotifyOfModification ();
  307.   }
  308. }
  309.  
  310. #pragma info (restore)
  311. #pragma pack ()
  312.