home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / iivmap.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  10.0 KB  |  369 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. // IVMapImpl
  23. // ---
  24.  
  25. // public members
  26.  
  27. template <class VInherited>
  28. IVMapImpl <VInherited>::
  29. IVMapImpl (Ops& ops, INumber numberOfElements)
  30. : VInherited (ops, numberOfElements)
  31. {
  32. }
  33.  
  34. template <class VInherited>
  35. IVMapImpl <VInherited>::
  36. IVMapImpl
  37.   (Ops& ops, IVMapImpl <VInherited> const& collection)
  38. : VInherited (ops, collection)
  39. {
  40. }
  41.  
  42. template <class VInherited>
  43. IBoolean
  44. IVMapImpl <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. IVMapImpl <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. IVMapImpl <VInherited>::
  72. AddAntivalence (IAMapImpl const& collection1,
  73.                 IAMapImpl 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. IVMapImpl <VInherited>::
  86. AddDifference (IAMapImpl const& collection1,
  87.                IAMapImpl 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. IVMapImpl <VInherited>::
  100. AddIntersection (IAMapImpl const& collection1,
  101.                IAMapImpl 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. IVMapImpl <VInherited>::
  114. AddUnion (IAMapImpl const& collection1,
  115.           IAMapImpl 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. IVMapImpl <VInherited>::
  128. Antivalence (IAMapImpl 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. IBoolean
  139. IVMapImpl <VInherited>::
  140. AddOrReplaceElementWithKey (void const* element, ICursorImpl& cursor)
  141. { IBoolean hasBeenAdded = false;
  142.   if (VInherited::LocateElementWithKey (Key (element), cursor)) {
  143.     if (HasObservers ()) {
  144. #if defined (ICLCC_COMPAT_IVB)
  145.       NotifyOfRemoveAt (cursor); // to be removed in a future release
  146. #else
  147.       NotifyOfReplaceAt (cursor, element);
  148. #endif
  149.     }
  150.     VInherited::ReplaceAt (cursor, element);
  151. #if defined (ICLCC_COMPAT_IVB)
  152.     if (HasObservers ()) {
  153.       NotifyOfAddAt (cursor); // to be removed in a future release
  154.     }
  155. #endif
  156.   }
  157.   else {
  158.     hasBeenAdded = VInherited::Add (element, cursor);
  159.     if (HasObservers ()) {
  160.       NotifyOfAddAt (cursor);
  161.     }
  162.   }
  163.   return hasBeenAdded;
  164. }
  165.  
  166. template <class VInherited>
  167. void
  168. IVMapImpl <VInherited>::
  169. Copy (IACollectionImpl const& collection)
  170. { IBoolean isEnabled = IsEnabledForNotification ();
  171.   DisableNotification ();
  172.   VInherited::Copy (collection);
  173.   EnableNotification (isEnabled);
  174.   if (HasObservers ()) {
  175.     NotifyOfModification ();
  176.   }
  177. }
  178.  
  179. template <class VInherited>
  180. void
  181. IVMapImpl <VInherited>::
  182. Difference (IAMapImpl const& collection)
  183. { IBoolean isEnabled = IsEnabledForNotification ();
  184.   DisableNotification ();
  185.   VInherited::Difference (collection);
  186.   EnableNotification (isEnabled);
  187.   if (HasObservers ()) {
  188.     NotifyOfModification ();
  189.   }
  190. }
  191.  
  192. template <class VInherited>
  193. void
  194. IVMapImpl <VInherited>::
  195. Intersection (IAMapImpl const& collection)
  196. { IBoolean isEnabled = IsEnabledForNotification ();
  197.   DisableNotification ();
  198.   VInherited::Intersection (collection);
  199.   EnableNotification (isEnabled);
  200.   if (HasObservers ()) {
  201.     NotifyOfModification ();
  202.   }
  203. }
  204. template <class VInherited>
  205. IBoolean
  206. IVMapImpl <VInherited>::
  207. LocateOrAdd (void const* element, ICursorImpl& cursor)
  208. { IBoolean isEnabled = IsEnabledForNotification ();
  209.   DisableNotification ();
  210.   IBoolean hasBeenLocated = VInherited::LocateOrAdd (element, cursor);
  211.   EnableNotification (isEnabled);
  212.   if (! hasBeenLocated && HasObservers ()) {
  213.     NotifyOfAddAt (cursor);
  214.   }
  215.   return hasBeenLocated;
  216. }
  217.  
  218. template <class VInherited>
  219. IBoolean
  220. IVMapImpl <VInherited>::
  221. LocateOrAddElementWithKey (void const* key, ICursorImpl& cursor)
  222. { IBoolean isEnabled = IsEnabledForNotification ();
  223.   DisableNotification ();
  224.   IBoolean hasBeenLocated =
  225.     VInherited::LocateOrAddElementWithKey (key, cursor);
  226.   EnableNotification (isEnabled);
  227.   if (!hasBeenLocated && HasObservers ()) {
  228.     NotifyOfAddAt (cursor);
  229.   }
  230.   return hasBeenLocated;
  231. }
  232.  
  233. template <class VInherited>
  234. IBoolean
  235. IVMapImpl <VInherited>::
  236. Remove (void const* element)
  237. { if (HasObservers () &&  Locate (element, CursorOf (*this))) {
  238.     NotifyOfRemoveAt (CursorOf (*this));
  239.   }
  240.   return VInherited::Remove (element);
  241. }
  242.  
  243. template <class VInherited>
  244. INumber
  245. IVMapImpl <VInherited>::
  246. RemoveAll ()
  247. { INumber result = VInherited::RemoveAll ();
  248.   if (result > 0 && HasObservers ()) {
  249.     NotifyOfModification ();
  250.   }
  251.   return result;
  252. }
  253.  
  254. template <class VInherited>
  255. INumber
  256. IVMapImpl <VInherited>::
  257. RemoveAll (IPredFunc predFunc, void* addArg)
  258. { INumber result = VInherited::RemoveAll (predFunc, addArg);
  259.   if (result > 0 && HasObservers ()) {
  260.     NotifyOfModification ();
  261.   }
  262.   return result;
  263. }
  264.  
  265. template <class VInherited>
  266. INumber
  267. IVMapImpl <VInherited>::
  268. RemoveAllElementsWithKey (void const* key)
  269. { IBoolean isEnabled = IsEnabledForNotification ();
  270.   DisableNotification ();
  271.   INumber result = VInherited::RemoveAllElementsWithKey (key);
  272.   EnableNotification (isEnabled);
  273.   if (result > 0 && HasObservers ()) {
  274.     NotifyOfModification ();
  275.   }
  276.   return result;
  277. }
  278.  
  279. template <class VInherited>
  280. INumber
  281. IVMapImpl <VInherited>::
  282. RemoveAllOccurrences (void const* element)
  283. { IBoolean isEnabled = IsEnabledForNotification ();
  284.   DisableNotification ();
  285.   INumber result = VInherited::RemoveAllOccurrences (element);
  286.   EnableNotification (isEnabled);
  287.   if (result > 0 && HasObservers ()) {
  288.     NotifyOfModification ();
  289.   }
  290.   return result;
  291. }
  292.  
  293. template <class VInherited>
  294. void
  295. IVMapImpl <VInherited>::
  296. RemoveAt (ICursorImpl& cursor)
  297. { if (HasObservers ()) {
  298.     NotifyOfRemoveAt (cursor);
  299.   }
  300.   VInherited::RemoveAt (cursor);
  301. }
  302.  
  303. template <class VInherited>
  304. IBoolean
  305. IVMapImpl <VInherited>::
  306. RemoveElementWithKey (void const* key)
  307. { if (HasObservers () &&
  308.       LocateElementWithKey (key, CursorOf (*this))) {
  309.     NotifyOfRemoveAt (CursorOf (*this));
  310.   }
  311.   return VInherited::RemoveElementWithKey (key);
  312. }
  313.  
  314. template <class VInherited>
  315. void
  316. IVMapImpl <VInherited>::
  317. ReplaceAt (ICursorImpl const& cursor, void const* element)
  318. { if (HasObservers ()) {
  319. #if defined (ICLCC_COMPAT_IVB)
  320.     NotifyOfRemoveAt (cursor); // to be removed in a future release
  321. #else
  322.     NotifyOfReplaceAt (cursor, element);
  323. #endif
  324.   }
  325.   VInherited::ReplaceAt (cursor, element);
  326. #if defined (ICLCC_COMPAT_IVB)
  327.   if (HasObservers ()) {
  328.     NotifyOfAddAt (cursor); // to be removed in a future release
  329.   }
  330. #endif
  331. }
  332.  
  333. template <class VInherited>
  334. IBoolean
  335. IVMapImpl <VInherited>::
  336. ReplaceElementWithKey (void const* element, ICursorImpl& cursor)
  337. { if (HasObservers ()) {
  338. #if defined (ICLCC_COMPAT_IVB)
  339.     NotifyOfRemoveAt (cursor); // to be removed in a future release
  340. #else
  341.     NotifyOfReplaceAt (cursor, element);
  342. #endif
  343.   }
  344.   IBoolean hasBeenReplaced =
  345.     VInherited::ReplaceElementWithKey (element, cursor);
  346. #if defined (ICLCC_COMPAT_IVB)
  347.   if (HasObservers ()) {
  348.     NotifyOfAddAt (cursor); // to be removed in a future release
  349.   }
  350. #endif
  351.   return hasBeenReplaced;
  352. }
  353.  
  354. template <class VInherited>
  355. void
  356. IVMapImpl <VInherited>::
  357. Union (IAMapImpl const& collection)
  358. { IBoolean isEnabled = IsEnabledForNotification ();
  359.   DisableNotification ();
  360.   VInherited::Union (collection);
  361.   EnableNotification (isEnabled);
  362.   if (HasObservers ()) {
  363.     NotifyOfModification ();
  364.   }
  365. }
  366.  
  367. #pragma info (restore)
  368. #pragma pack ()
  369.