Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef XObjectTreeSynchronizerH
00033 #define XObjectTreeSynchronizerH
00034
00035 #include <zeusbase/System/Interfaces/IXObject.hpp>
00036 #include <zeusbase/System/Interfaces/IXSynchronAction.hpp>
00037 #include <zeusbase/System/ZObject.h>
00038 #include <zeusbase/System/StringMap.hpp>
00039 #include <zeusbase/System/SingleLinkedList.hpp>
00040
00041 BEGIN_NAMESPACE_Zeus
00042
00043 class TXSynchronAction;
00044 class IXSynchronActionListener;
00045
00046
00053
00054 zeusbase_class TXObjectTreeSynchronizer : public TZObject
00055 {
00056 public:
00057 TXObjectTreeSynchronizer();
00058
00059 Retval synchronizeTree(IXObject& rSource, IXObject& rTarget);
00060 Retval getRootAction(IXSynchronAction*& rpObject);
00061 Retval getSubAction(IXObject* pRefObject, IXSynchronAction*& rpObject);
00062
00063 Retval executeRootAction(IXSynchronActionListener* pListener = NULL);
00064 Retval executeSubAction(IXObject* pRefObject, IXSynchronActionListener* pListener = NULL);
00065
00066 void setUnfreezeFlag(bool bUnfreeze);
00067 void setCleanTreeFlag(bool bClean);
00068 void setForceChangeActions(bool bForceChanges);
00069 void setNumberOfCycles(Int iCycleCount);
00070 void setAutoCheck(bool bValue);
00071
00072 void MQUALIFIER reset();
00073
00074 protected:
00075 virtual ~TXObjectTreeSynchronizer();
00076
00077 private:
00079 IXObject* m_pSourceTree;
00081 IXObject* m_pTargetTree;
00083 IXSynchronAction* m_pActionTree;
00085 bool m_bUnfreeze;
00087 bool m_bCleanTree;
00089 bool m_bForceChanges;
00091 bool m_bAutoCheckNodes;
00093 Int m_iCycleCount;
00094
00095
00096
00097
00101
00102 struct TypDataRecord
00103 {
00104 TString strKey;
00105 IXObject* pObject;
00106
00107 TypDataRecord()
00108 {
00109 pObject = NULL;
00110 }
00111
00112 TypDataRecord(const TString& rName, IXObject& rObject)
00113 {
00114 strKey = rName;
00115 pObject = &rObject;
00116 }
00117
00118 bool operator==(const TypDataRecord& rInPar) const
00119 {
00120 return (strKey == rInPar.strKey &&
00121 pObject == rInPar.pObject);
00122 }
00123
00124 };
00125
00126 void releaseInstances();
00127 void fillMapWithChildObjects(IXObject& rParent, TStringMap<IXObject*>& rMapChildren);
00128 void fillListWithChildObjects(IXObject& rParent, TSingleLinkedList<TypDataRecord>& rChildren);
00129 void synchronizeTree_internal(IXObject* pSource, IXObject* pTarget, IXSynchronAction& rAction);
00130 Retval checkForChanges(IXObject* pSource, IXObject* pTarget, IXSynchronAction& rAction, IXSynchronAction*& rpChildAction);
00131 TString generateKeyName(IXObject& rObject);
00132 };
00133
00134
00135
00136
00140
00141 inline void TXObjectTreeSynchronizer::setUnfreezeFlag(bool bUnfreeze)
00142 {
00143 m_bUnfreeze = bUnfreeze;
00144 }
00145
00146
00150
00151 inline void TXObjectTreeSynchronizer::setCleanTreeFlag(bool bClean)
00152 {
00153 m_bCleanTree = bClean;
00154 }
00155
00156
00159
00160 inline void TXObjectTreeSynchronizer::setForceChangeActions(bool bForceChanges)
00161 {
00162 m_bForceChanges = bForceChanges;
00163 }
00164
00165
00170
00171 inline void TXObjectTreeSynchronizer::setAutoCheck(bool bValue)
00172 {
00173 m_bAutoCheckNodes = bValue;
00174 }
00175
00176
00179
00180 inline void MQUALIFIER TXObjectTreeSynchronizer::reset()
00181 {
00182 releaseInstances();
00183 }
00184
00185
00186
00189
00190 inline void TXObjectTreeSynchronizer::setNumberOfCycles(Int iCycleCount)
00191 {
00192 m_iCycleCount = iCycleCount;
00193 }
00194
00195
00200
00201 inline TString TXObjectTreeSynchronizer::generateKeyName(IXObject& rObject)
00202 {
00203 TString strName;
00204 TString strClassName;
00205 TString strID((long)rObject.getID());
00206 rObject.getName(strName);
00207 rObject.getClassName(strClassName);
00208
00209 TString strKey;
00210 strKey.concatStr(strName);
00211 strKey.concat(L"[");
00212 strKey.concatStr(strID);
00213 strKey.concat(L"]");
00214 strKey.concat(L"::");
00215 strKey.concatStr(strClassName);
00216
00217 return strKey;
00218 }
00219
00220
00221 END_NAMESPACE_Zeus
00222
00223 #endif