Changeset 126 for XMLIO_V2/dev/dev_rv/src/XMLIO/object_template.hpp
- Timestamp:
- 10/07/10 10:29:38 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/src/XMLIO/object_template.hpp
r125 r126 27 27 28 28 if (c.baseObject != NULL) 29 out << IncIndent << "<-- Reference resolved for the following "+ T::GetName() + 30 " : \"" << c.baseObject->getId() << "\" -->" << DecEndl << std::endl; 29 out << IncIndent << "<-- Référence résolu sur l'instance de "<< T::GetName() 30 << " nommée \"" << c.baseObject->getId() << "\" -->" << DecEndl << std::endl; 31 32 if (c.isDefinition()) 33 { 34 out << NIndent << std::endl; 35 out << NIndent << "<!-- Groupe de définition dans le contexte \"" << ObjectTemplate<T>::GetCurrentContextId() << "\" courant -->" << std::endl; 36 } 31 37 32 38 if (c.hasChild()) 33 39 { 34 out << IncIndent << "<" << c.getName()<< c.printId() << ar << ">" << std::endl;40 out << IncIndent << "<" << c.getName() << c.printId() << ar << ">" << std::endl; 35 41 c.printChild(out); // << Ecriture des objets enfants ici. 42 if (c.hasId() && (c.getName().compare("context") == 0)) 43 out << NIndent << std::endl; 36 44 out << NIndent << "</" << c.getName() << ">" << DecEndl; 37 45 } 38 else out << IncIndent << "<" << c.getName() << c.printId() << ar << "/>" << DecEndl; 46 else 47 out << IncIndent << "<" << c.getName() << c.printId() << ar << "/>" << DecEndl; 39 48 40 49 return (out); 41 50 } 42 51 52 bool isDefinition(void) const 53 { 54 if (!this->hasId()) return (false); 55 return (this->getName().compare(this->getId()) == 0); 56 } 57 43 58 string getName(void) const 44 59 { 45 if ( hasId())60 if (this->hasId()) 46 61 if (T::GetDefName().compare(getId()) == 0) 47 return T::GetDefName();62 return (T::GetDefName()); 48 63 return (T::GetName()); 49 64 } … … 51 66 T* getBaseObject(void) const { return (baseObject); } 52 67 53 virtual T* getReference(void) const { return (NULL); }54 55 68 const vector<T*>& getVectRefObject(void) const { return (refObject); } 56 69 57 bool hasRefObject(void) { return (!refObject.empty()); }70 bool hasRefObject(void) const { return (!refObject.empty()); } 58 71 59 72 const T* addRefObject(T* obj) 60 73 { refObject.push_back (obj); return (obj); } 61 74 75 public : /* virtual */ 76 77 virtual T* getReference(void) const { return (NULL); } 62 78 virtual bool hasChild(void) const { return (false); } 63 virtual void printChild(ostream& out) const { out << NIndent << "<!-- No child -->" << std::endl; } 64 65 virtual void resolveDescInheritance(const AttributRegistrar* _parent = 0) { addAttributes(*_parent); } 79 80 virtual void printChild(ostream& out) const 81 { out << NIndent << "<!-- No child -->" << std::endl; } 82 83 virtual void resolveDescInheritance(const AttributRegistrar* _parent = 0) 84 { this->addAttributes(*_parent); } 85 66 86 virtual void resolveRefInheritance (void) 67 87 { … … 89 109 90 110 /// PARSING POUR GESION DES ENFANTS /// 91 // Rien à faire. 92 } 111 // Rien à faire ici. 112 } 113 114 virtual ~ObjectTemplate(void) 115 {/* Ne rien faire de plus */} 93 116 94 117 public : /* static */ … … 118 141 static bool HasObject(const string& _id) 119 142 { 120 if(ObjectTemplate<T>::AllListObj.find(CurrContext) == ObjectTemplate<T>::AllListObj.end()) return false; 143 if(ObjectTemplate<T>::AllListObj.find(CurrContext) == 144 ObjectTemplate<T>::AllListObj.end()) 145 return (false); 121 146 return (ObjectTemplate<T>::AllListObj[CurrContext].hasMappedValue(_id)); 122 147 } … … 125 150 static Poco::HashMap<string, StrHashMap<T> >& GetAllListObject(void) { return (AllListObj); } 126 151 127 static void SetContext(const string& id){ ObjectTemplate<T>::CurrContext = id; } 128 129 static string& GetCurrentContextId(void) { return (CurrContext); } 130 131 virtual ~ObjectTemplate(void) 132 {/* Ne rien faire de plus */} 152 static void SetContext(const string& id) { ObjectTemplate<T>::CurrContext = id; } 153 154 static string& GetCurrentContextId(void) { return (ObjectTemplate<T>::CurrContext); } 133 155 134 156 protected : 135 157 136 ObjectTemplate(void) : AbstractObject(), baseObject(NULL), refObject() 137 {/* Ne rien faire de plus */} 138 ObjectTemplate(const string& _id) : AbstractObject(_id), baseObject(NULL), refObject() 139 {/* Ne rien faire de plus */} 158 ObjectTemplate(void) 159 : AttributRegistrar(), AbstractObject(), baseObject(NULL), refObject() 160 { /* Ne rien faire de plus */ } 161 162 ObjectTemplate(const string& _id) 163 : AttributRegistrar(), AbstractObject(_id), baseObject(NULL), refObject() 164 { /* Ne rien faire de plus */ } 165 166 ObjectTemplate(const ObjectTemplate<T>& _ot, bool _withAttrList = true, bool _withId = true) 167 : AttributRegistrar(), AbstractObject(), baseObject(_ot.baseObject), refObject(_ot.refObject) 168 { 169 // Si requis, ajout de l'identifiant lors de la copie. 170 if (_ot.hasId() && _withId) this->setId(_ot.getId()); 171 // Si requis, ajout des attributs lors de la copie. 172 if (_withAttrList) this->addAttributes(_ot); 173 } 140 174 141 175 XML::XMLNode getNodeIncludedFile(const string& path, const string& _rootName) 142 176 { 143 177 ifstream istr( path.c_str() , ifstream::in ); 144 return XML::XMLNode::CreateNode(istr, _rootName);178 return (XML::XMLNode::CreateNode(istr, _rootName)); 145 179 } 146 180 … … 151 185 { 152 186 if (V::HasObject(did)) 153 WARNING("Le noeud nommé \""+ did +"\" existe déjà pour les instances de type "+V::GetName()+", le dernier défini complétera le premier dans le context actuel!"); 187 WARNING("Le noeud nommé \""+ did +"\" existe déjà pour les instances de type "+ 188 V::GetName()+", le dernier défini complétera le premier dans le context actuel!"); 154 189 instance_ptr = (V*)V::CreateObject(did); 155 190 instance_ptr->parse(_node, parseAttr); … … 159 194 160 195 private : 196 161 197 T* baseObject; 162 vector<T*> refObject; 198 std::vector<T*> refObject; 199 200 private : /* static */ 163 201 164 202 static string CurrContext; … … 167 205 };// class ObjectTemplate 168 206 207 // Initialisation des variables statiques de la classe ObjectTemplate. 169 208 template <class T> string ObjectTemplate<T>::CurrContext ; 170 209 template <class T> Poco::HashMap<string, StrHashMap<T> > ObjectTemplate<T>::AllListObj;
Note: See TracChangeset
for help on using the changeset viewer.