00001 /* 00002 ***************************************************************** 00003 ***************************************************************** 00004 ******* ******** 00005 ******* (C) Copyright 1989-2007 by Tecplot Inc. ******** 00006 ******* All Rights Reserved. ******** 00007 ******* ******** 00008 ***************************************************************** 00009 ***************************************************************** 00010 */ 00011 #ifndef TECPLOT_TOOLBOX_STATECHANGENOTIFIER_H 00012 #define TECPLOT_TOOLBOX_STATECHANGENOTIFIER_H 00013 00014 #if defined MSWIN 00015 #pragma once 00016 #endif 00017 00018 #include <set> 00019 #include "Uncopyable.h" 00020 #include "StateChangeNotifierInterface.h" 00021 #include "StateChangeEventInterface.h" 00022 #include "Set.h" 00023 #include "StringList.h" 00024 #include "ToolboxFwd.h" 00025 00026 namespace tecplot 00027 { 00028 namespace toolbox 00029 { 00030 00036 class TPTOOLBOX_DLLAPI StateChangeNotifier : public StateChangeNotifierInterface 00037 { 00038 public: 00039 StateChangeNotifier(StateChangeMode_e stateChangeMode = StateChangeMode_v100); 00040 virtual ~StateChangeNotifier(); 00041 00044 void addListener(StateChangeListenerInterface* listener); 00045 00048 void removeListener(StateChangeListenerInterface* listener); 00049 00052 bool isListening(StateChangeListenerInterface* listener); 00053 00056 bool setMode(StateChangeMode_e mode); 00059 StateChangeMode_e mode(); 00060 00118 static void sendStateChange(StateChange_e stateChange, 00119 const Set& zoneSet = Set(), 00120 const Set& varSet = Set(), 00121 LgIndex_t index = TECUTILBADID); 00122 protected: 00135 virtual void onStateChanged(const StateChangeEventInterface& stateChangeEvent); 00136 00144 void notifyOfStateChanged(const StateChangeEventInterface& stateChangeEvent); 00145 00146 00147 private: 00153 virtual void lockStart() {} 00154 virtual void lockFinish() {} 00155 00156 static void staticStateChangeCallback(StateChange_e stateChange, 00157 ArbParam_t clientData); 00158 00164 void addStateChangeCallback(); 00165 void removeStateChangeCallback(); 00166 bool m_stateChangeCallbackIsRegistered; 00167 StateChangeMode_e m_stateChangeMode; 00168 00169 typedef std::set<StateChangeListenerInterface*> ListenerSet_t; 00170 ListenerSet_t m_listeners; 00171 00172 UNCOPYABLE_CLASS(StateChangeNotifier); 00173 00174 private: 00183 class StateChangeEvent : public StateChangeEventInterface 00184 { 00185 public: 00186 StateChangeEvent(StateChange_e stateChange); 00187 ~StateChangeEvent(); 00188 public: 00189 const StateChangeEventInterface* clone() const; 00190 00191 bool hasIndex() const; 00192 bool hasVarSet() const; 00193 bool hasZoneSet() const; 00194 bool hasLineMapSet() const; 00195 bool hasFieldMapSet() const; 00196 bool hasArbEnum() const; 00197 bool hasStyleParams() const; 00198 bool hasMap() const; 00199 bool hasZone() const; 00200 bool hasVar() const; 00201 bool hasName() const; 00202 bool hasPageUniqueID() const; 00203 bool hasFrameUniqueID() const; 00204 bool hasDataSetUniqueID() const; 00205 bool hasUniqueID() const; 00206 bool hasOffset1() const; 00207 bool hasOffset2() const; 00208 00209 StateChange_e getStateChange() const; 00210 LgIndex_t getIndex() const; 00211 const Set& getVarSet() const; 00212 const Set& getZoneSet() const; 00213 const Set& getLineMapSet() const; 00214 const Set& getFieldMapSet() const; 00215 LgIndex_t getArbEnum() const; 00216 const StringList& getStyleParams() const; 00217 std::string getStyleParam(int param) const; 00218 EntIndex_t getMap() const; 00219 EntIndex_t getZone() const; 00220 EntIndex_t getVar() const; 00221 std::string getName() const; 00222 UniqueID_t getPageUniqueID() const; 00223 UniqueID_t getFrameUniqueID() const; 00224 UniqueID_t getDataSetUniqueID() const; 00225 UniqueID_t getUniqueID() const; 00226 LgIndex_t getOffset1() const; 00227 LgIndex_t getOffset2() const; 00228 00229 private: 00230 StateChange_e m_stateChange; 00231 LgIndex_t m_index; 00232 Set m_varSet; 00233 Set m_zoneSet; 00234 Set m_lineMapSet; 00235 Set m_fieldMapSet; 00236 LgIndex_t m_arbEnum; 00237 StringList m_styleParams; 00238 EntIndex_t m_map; 00239 EntIndex_t m_zone; 00240 EntIndex_t m_var; 00241 std::string m_name; 00242 UniqueID_t m_pageUniqueID; 00243 UniqueID_t m_frameUniqueID; 00244 UniqueID_t m_dataSetUniqueID; 00245 UniqueID_t m_uniqueID; 00246 LgIndex_t m_offset1; 00247 LgIndex_t m_offset2; 00248 }; 00249 }; 00250 00251 } 00252 } 00253 00254 #endif