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 #ifndef FSF_NODE_H
00030 #define FSF_NODE_H
00031
00032 #include "Fsf.h"
00033
00034 #include <string>
00035 #include <list>
00036
00037
00038 namespace fsf{
00039
00053
00054
00055
00056 class CPulse;
00057 template <class T> class CPassiveFilter;
00058 class CPassiveHandle;
00059
00060
00063 class CNode{
00064 private:
00065 CNode *m_pParent;
00066
00067 Time m_tTime;
00068 Time m_tDuration;
00069
00070 CMutex m_csName;
00071 std::string m_strName;
00072
00073 bool m_bNotDeleted;
00074 bool m_bNoDelete;
00075
00076
00077 CMutex m_csHandleRefs;
00078 long m_nNbHandleRefs;
00079
00080 CMutex m_csComponents;
00081 std::list<CNode*> m_listComponents;
00082
00088
00089 bool wildcardMatch(const std::string &strWildcard, const std::string &strTest) const;
00090 bool wildcardMatch(const char *wildcard, const char *test) const;
00091 bool set (const char **wildcard, const char **test) const;
00092 bool star (const char **wildcard, const char **test) const;
00094
00095 protected:
00098 std::list<CNode*> &getListComponents() { return m_listComponents; }
00099
00100 public:
00101
00103
00104
00105 CNode()
00106 : m_pParent(NULL), m_tTime(0), m_tDuration(0),
00107 m_bNotDeleted(true), m_bNoDelete(false), m_nNbHandleRefs(0) {}
00109 CNode(CNode *pParent, Time tTime=0)
00110 : m_pParent(pParent), m_tTime(tTime), m_tDuration(0),
00111 m_bNotDeleted(true), m_bNoDelete(false), m_nNbHandleRefs(0) {}
00113 CNode(const std::string &strName, CNode *pParent=NULL, Time tTime=0)
00114 : m_pParent(pParent), m_tTime(tTime), m_tDuration(0),
00115 m_strName(strName), m_bNotDeleted(true), m_bNoDelete(false), m_nNbHandleRefs(0) {}
00117 CNode(const CNode& rhs)
00118 : m_pParent(NULL), m_tTime(rhs.m_tTime), m_tDuration(rhs.m_tDuration),
00119 m_strName(rhs.m_strName), m_bNotDeleted(rhs.m_bNotDeleted), m_bNoDelete(rhs.m_bNoDelete),
00120 m_nNbHandleRefs(0) {}
00122 virtual ~CNode();
00124 virtual CNode *clone() const { return new CNode(*this); }
00126
00128
00129
00130 CNode& operator=(const CNode& rhs){
00131 m_tTime=rhs.m_tTime;
00132 m_tDuration=rhs.m_tDuration;
00133 m_strName=rhs.m_strName;
00134 m_bNotDeleted=rhs.m_bNotDeleted;
00135 m_bNoDelete=rhs.m_bNoDelete;
00136 m_nNbHandleRefs=0; return *this;
00137 }
00138
00140 void setTime(Time tTime) { m_tTime=tTime; }
00142 void setDuration(Time tDuration) { m_tDuration=tDuration; }
00144 void setName(const std::string &strName){
00145 m_csName.lock();
00146 m_strName.assign(strName);
00147 m_csName.unlock();
00148 }
00150 void setParent(CNode *pParent) { m_pParent=pParent; }
00154 void setDeleted() { m_bNotDeleted=false; }
00156 void setNoDelete(bool bNoDelete=true) { m_bNoDelete=bNoDelete; }
00157
00159 virtual bool deleteNode(bool bForce=false);
00160
00162 virtual void addComponent(CNode *pNode){
00163 m_csComponents.lock();
00164 m_listComponents.push_front(pNode);
00165 m_csComponents.unlock();
00166 }
00167
00169 virtual void addComponent(CNode *pNode, int nMode, CNode *pReference=NULL);
00170 virtual bool removeComponent(CNode *pNode);
00171
00173 virtual void cleanUpComponents(std::list<CNode*> &listNodes);
00174
00175
00177 virtual void generateChildrenList(std::list<CNode*> &listNode);
00179 virtual void generateChildrenHandleList(std::list<CPassiveHandle*> &listHandles);
00180
00181
00184 void getName(std::string &strName){
00185 m_csName.lock();
00186 strName.assign(m_strName);
00187 m_csName.unlock();
00188 }
00192 virtual CPulse *getPulse() { return (m_pParent!=NULL)?(m_pParent->getPulse()):(NULL); }
00194
00196
00197
00199
00200
00203 virtual void getTypeID(std::string &str) const { str.assign("FSF_NODE"); }
00204
00206 Time getTime() const { return m_tTime; }
00208 Time getDuration() const { return m_tDuration; }
00209
00210 CNode *getParent() const { return m_pParent; }
00212 bool isNotDeleted() const { return m_bNotDeleted; }
00214 bool canDelete() const { return (m_bNoDelete==false); }
00215
00217
00218
00220
00221
00222 std::string& name() { return m_strName; }
00224 bool testNameExact(const std::string &str) const { return str==m_strName; }
00226 bool testNameWildcard(const std::string &str) const { return wildcardMatch(str,m_strName); }
00228 void incNbHandleRefs() { m_csHandleRefs.lock(); m_nNbHandleRefs++; m_csHandleRefs.unlock(); }
00230 void decNbHandleRefs() { m_csHandleRefs.lock(); m_nNbHandleRefs--; m_csHandleRefs.unlock(); }
00232
00233 };
00234
00235 }
00236
00237 #endif // FSF_NODE_H
00238