InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ListLazyNotificationData.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Ryan Gano
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //========================================================================================
23 
24 #ifndef __ListLazyNotifsCookie__
25 #define __ListLazyNotifsCookie__
26 
27 #include "LazyNotificationData.h"
28 #include "KeyValuePair.h"
29 #include <vector>
30 
31 // The is a templated class so that clients can store data in the way that is
32 // most fitting for them. Two types of templates have been pre-defined.
33 // The first takes a UID and the second takes a ClassID.
34 // To add new types you must include the file LazyNotificationData.tpp so that
35 // the correct templated class can be compiled. Typically this is done in one
36 // location to avoid having to recompile the same template code over and over
37 // again. For app wide usage (things that you expect multiple plugins to have
38 // need of please put your definition in templates_pub.cpp. For plugin specific
39 // templates you can create a similar file in your plugin and add the definiation
40 // there. The definition should look like:
41 // template class ListLazyNotificationData<UID>;
42 
46 template <class ItemType>
48 {
49 public:
51  ListLazyNotificationData():LazyNotificationData(), fRebuildWholeList(false){};
52 
62  virtual void Add (const LazyNotificationData* other);
63 
77  virtual LazyNotificationData* Clone (bool16 undoData) const;
78 
86  virtual void MarkShouldRebuildAll ();
87 
88  void ItemAdded(ItemType itemID);
89 
95  void ItemDeleted(ItemType itemID);
96 
102  void ItemChanged(ItemType itemID);
103 
115  void BreakoutChanges(K2Vector<ItemType> *addedItems, K2Vector<ItemType> *deletedItems, K2Vector<ItemType> *changedItems) const;
116 
119  bool ShouldRebuildAll() const {return fRebuildWholeList;}
120 
130  virtual void Validate(IDataBase *db);
131 
132 
133 private:
134 
135  // Used as an indicator of how a particular item changed (used internally)
136  enum ListCookieItemState {
137  // Indicates that the item was added
138  kAdded,
139  // Indicates that the item was deleted
140  kDeleted,
141  // Indicates that the item was changed
142  kChanged
143  };
144 
145  // A typedef to make less typing. Combines an item and state.
146  typedef KeyValuePair<ItemType, ListCookieItemState> StoredItemData;
147  // A typedef to make less typing. Vector of items and states
148  typedef std::vector<StoredItemData> ItemTypeVector;
149 
150  // This is the list of items and their changes
151  std::vector<StoredItemData> fItemList;
152 
153  // This bool indicates whether the entire list should just be rebuilt
154  bool fRebuildWholeList;
156  enum {kMaxSize = 100};
157 };
158 
159 #endif