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 "Uncopyable.h" 00019 #include "StateChangeNotifierInterface.h" 00020 #include "StateChangeEventInterface.h" 00021 #include "Set.h" 00022 #include "StringList.h" 00023 #include <set> 00024 00025 namespace tecplot { namespace toolbox { 00026 00027 class OutOfMemoryException; 00028 00034 class TPTOOLBOX_DLLAPI StateChangeNotifier : public StateChangeNotifierInterface 00035 { 00036 public: 00037 StateChangeNotifier(StateChangeMode_e stateChangeMode = StateChangeMode_v100); 00038 virtual ~StateChangeNotifier(); 00039 00054 void addListener(StateChangeListenerInterface * const listener) throw (OutOfMemoryException); 00055 00067 void removeListener(StateChangeListenerInterface * const listener); 00068 00124 static void sendStateChange(StateChange_e stateChange, 00125 const Set& zoneSet = Set(), 00126 const Set& varSet = Set(), 00127 LgIndex_t index = TECUTILBADID); 00139 bool isListening(StateChangeListenerInterface * const listener); 00140 00141 protected: 00154 virtual void onStateChanged(const StateChangeEventInterface& stateChangeEvent); 00155 00163 void notifyOfStateChanged(const StateChangeEventInterface& stateChangeEvent); 00164 00165 00166 private: 00172 virtual void lockStart(){} 00173 virtual void lockFinish(){} 00174 00175 static void staticStateChangeCallback(StateChange_e stateChange, 00176 ArbParam_t clientData); 00177 00183 void addStateChangeCallback() throw (OutOfMemoryException); 00184 void removeStateChangeCallback(); 00185 bool m_stateChangeCallbackIsRegistered; 00186 StateChangeMode_e m_stateChangeMode; 00187 00188 typedef std::set<StateChangeListenerInterface*> ListenerSet_t; 00189 ListenerSet_t m_listeners; 00190 00191 UNCOPYABLE_CLASS(StateChangeNotifier); 00192 00193 private: 00202 class StateChangeEvent : public StateChangeEventInterface 00203 { 00204 public: 00205 StateChangeEvent(StateChange_e stateChange); 00206 ~StateChangeEvent(); 00207 public: 00208 const StateChangeEventInterface* clone() const; 00209 00210 bool hasIndex() const; 00211 bool hasVarSet() const; 00212 bool hasZoneSet() const; 00213 bool hasLineMapSet() const; 00214 bool hasFieldMapSet() const; 00215 bool hasArbEnum() const; 00216 bool hasStyleParams() const; 00217 bool hasMap() const; 00218 bool hasZone() const; 00219 bool hasVar() const; 00220 bool hasName() const; 00221 bool hasPageUniqueID() const; 00222 bool hasFrameUniqueID() const; 00223 bool hasDataSetUniqueID() const; 00224 bool hasUniqueID() const; 00225 bool hasOffset1() const; 00226 bool hasOffset2() const; 00227 00228 StateChange_e getStateChange() const; 00229 LgIndex_t getIndex() const; 00230 const Set& getVarSet() const; 00231 const Set& getZoneSet() const; 00232 const Set& getLineMapSet() const; 00233 const Set& getFieldMapSet() const; 00234 LgIndex_t getArbEnum() const; 00235 const StringList& getStyleParams() const; 00236 std::string getStyleParam(int param) const; 00237 EntIndex_t getMap() const; 00238 EntIndex_t getZone() const; 00239 EntIndex_t getVar() const; 00240 std::string getName() const; 00241 UniqueID_t getPageUniqueID() const; 00242 UniqueID_t getFrameUniqueID() const; 00243 UniqueID_t getDataSetUniqueID() const; 00244 UniqueID_t getUniqueID() const; 00245 LgIndex_t getOffset1() const; 00246 LgIndex_t getOffset2() const; 00247 00248 private: 00249 StateChange_e m_stateChange; 00250 LgIndex_t m_index; 00251 Set m_varSet; 00252 Set m_zoneSet; 00253 Set m_lineMapSet; 00254 Set m_fieldMapSet; 00255 LgIndex_t m_arbEnum; 00256 StringList m_styleParams; 00257 EntIndex_t m_map; 00258 EntIndex_t m_zone; 00259 EntIndex_t m_var; 00260 std::string m_name; 00261 UniqueID_t m_pageUniqueID; 00262 UniqueID_t m_frameUniqueID; 00263 UniqueID_t m_dataSetUniqueID; 00264 UniqueID_t m_uniqueID; 00265 LgIndex_t m_offset1; 00266 LgIndex_t m_offset2; 00267 }; 00268 }; 00269 00270 }} 00271 00272 #endif
1.5.5