00001 /****************************************************************************** 00002 ** Copyright (c) 1992-2010 VT MAK 00003 ** All rights reserved. 00004 ******************************************************************************/ 00005 00009 00010 #pragma once 00011 00012 #include "stateObserver.h" 00013 00014 #include <lgrDriver.h> 00015 #include <observe.h> 00016 #include <set> 00017 00018 namespace MAKLogger 00019 { 00020 class DtCommand; 00021 class DtLgrSystemDriver; 00022 class DtMessageState; 00023 class DtStateObject; 00024 class DtStateObserverController; 00025 00030 class DT_DLL_STATEOBSERVER DtStateObserverModel : public MAKLogger::DtLgrCommandHandler 00031 { 00032 public: 00033 00035 DtStateObserverModel(DtStateObserverController*, 00036 MAKLogger::DtLgrSystemDriver& driver); 00037 00039 virtual ~DtStateObserverModel(); 00040 00042 void connect(MAKLogger::DtMessageState*); 00043 00045 int totalObjects() const; 00046 00048 int totalAliveObjects() const; 00049 00051 int totalDeadObjects() const; 00052 00054 int entityCount() const; 00055 00057 int aggregateCount() const; 00058 00060 int envProcCount() const; 00061 00062 //DtLgrCommandHandler Interface 00063 // Tick the driver, cause it to do anything on a regular basis. 00064 virtual void tick(); 00065 00066 // These are no-ops since this Handler doesn't use the pipeline. 00067 virtual bool releasePipeline(); 00068 virtual bool getPipeline(); 00069 virtual bool hasPipeline() const; 00070 00072 virtual DtResponse handleUpdateRequest(const DtCommand&); 00073 00075 virtual void enableObservers(); 00076 00078 virtual void disableObservers(); 00079 00080 protected: 00081 00083 static bool equals(const MAKLogger::DtStateObject* object,DtU64 id); 00084 00086 virtual void updateState(const MAKLogger::DtMessageState&); 00087 00089 virtual void activate(const MAKLogger::DtMessageState&); 00090 00092 virtual void deactivate(const MAKLogger::DtMessageState&); 00093 00095 virtual void endDiff(const MAKLogger::DtMessageState& state); 00096 00097 typedef MAKLogger::DtObserverFunctor<DtStateObserverModel,\ 00098 MAKLogger::DtMessageState> MessageStateObserverFunctor; 00099 00100 MessageStateObserverFunctor myPostUpdateObserver; 00101 MessageStateObserverFunctor myActivateObserver; 00102 MessageStateObserverFunctor myDeactivateObserver; 00103 MessageStateObserverFunctor myEndDiffObserver; 00104 00105 std::set<DtU64> myActiveObjects; 00106 00107 int myTotalCount; 00108 int myTotalAliveCount; 00109 int myTotalDeadCount; 00110 int myEntityCount; 00111 int myAggregateCount; 00112 int myEnvProcCount; 00113 00114 DtStateObserverController* myController; 00115 00116 bool myActivateObserverFlag; 00117 }; 00118 } 00119