Changeset 134 for XMLIO_V2/dev/dev_rv/src/XMLIO/context.hpp
- Timestamp:
- 10/15/10 11:16:12 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/src/XMLIO/context.hpp
r132 r134 5 5 namespace XMLIOSERVER 6 6 { 7 class DataTreatment; 8 7 9 class Context : public ObjectTemplate<Context> 8 10 { … … 10 12 11 13 Context(void) 12 : ObjectTemplate<Context>(), ccalendar(NULL), 14 : ObjectTemplate<Context>(), 15 dtreatment(NULL), ccalendar(NULL), 13 16 fieldDef(NULL), fileDef(NULL), axisDef(NULL), gridDef(NULL), domainDef(NULL) 14 { /* Ne rien faire de plus */}17 { /* Ne rien faire de plus */ } 15 18 16 19 Context(const string& _id) 17 : ObjectTemplate<Context>(_id), ccalendar(NULL), 20 : ObjectTemplate<Context>(_id), 21 dtreatment(NULL), ccalendar(NULL), 18 22 fieldDef(NULL), fileDef(NULL), axisDef(NULL), gridDef(NULL), domainDef(NULL) 19 { /* Ne rien faire de plus */}20 21 FieldDefinition* getFieldDefinition (void) const { return (this->fieldDef ); }22 FileDefinition* getFileDefinition (void) const { return (this->fileDef ); }23 AxisDefinition* getAxisDefinition (void) const { return (this->axisDef ); }24 GridDefinition* getGridDefinition (void) const { return (this->gridDef ); }23 { /* Ne rien faire de plus */ } 24 25 FieldDefinition * getFieldDefinition (void) const { return (this->fieldDef ); } 26 FileDefinition * getFileDefinition (void) const { return (this->fileDef ); } 27 AxisDefinition * getAxisDefinition (void) const { return (this->axisDef ); } 28 GridDefinition * getGridDefinition (void) const { return (this->gridDef ); } 25 29 DomainDefinition * getDomainDefinition(void) const { return (this->domainDef); } 26 30 27 AbstractCalendar * getCalendar(void) const { return (this->ccalendar ); } 31 AbstractCalendar * getCalendar (void) const { return (ccalendar ); } 32 DataTreatment * getDataTreatment(void) const { return (dtreatment); } 28 33 29 34 AbstractCalendar * setCalendar(const string& _calName, const string& _dateStr) 30 35 { 36 if(ccalendar != NULL) delete ccalendar; 37 31 38 if (_calName.compare("D360") == 0) 32 39 return (ccalendar = new D360Calendar(_dateStr)); … … 45 52 } 46 53 47 ~Context(void) 54 template <class T> 55 DataTreatment * setDataTreatment(void) 56 { return (dtreatment = (ccalendar == NULL)? NULL : new T(this)); } 57 58 public : /* virtual */ 59 60 virtual ~Context(void) 48 61 { 49 62 // Désallocation dynamique de mémoire pour chacun des groupes de définition si nécessaire. 50 if( fieldDef != NULL) delete fieldDef; if(fileDef != NULL) delete fileDef ;51 if( axisDef != NULL) delete axisDef; if(gridDef != NULL) delete gridDef ;63 if( fieldDef != NULL) delete fieldDef ; if(fileDef != NULL) delete fileDef ; 64 if( axisDef != NULL) delete axisDef ; if(gridDef != NULL) delete gridDef ; 52 65 if(domainDef != NULL) delete domainDef ; 53 66 54 67 // Désallocation dynamique de mémoire pour le calendrier associé au contexte courant si nécessaire. 55 if(ccalendar != NULL) delete ccalendar; 56 } 57 58 public : /* virtual */ 68 if(ccalendar != NULL) delete ccalendar; 69 // INFO La mémoire dédiée à dtreatment est désallouée ailleurs. 70 } 59 71 60 72 virtual void parse (XMLNode& _node) … … 117 129 virtual void printChild(ostream& out) const 118 130 { 119 if( fieldDef != NULL) out << *(FieldGroup*) fieldDef<< std::endl;120 if( fileDef != NULL) out << *(FileGroup*) fileDef<< std::endl;121 if( axisDef != NULL) out << *(AxisDefinition*) axisDef<< std::endl;122 if( gridDef != NULL) out << *(GridDefinition*) gridDef<< std::endl;131 if( fieldDef != NULL) out << *( FieldDefinition*) fieldDef << std::endl; 132 if( fileDef != NULL) out << *( FileDefinition*) fileDef << std::endl; 133 if( axisDef != NULL) out << *( AxisDefinition*) axisDef << std::endl; 134 if( gridDef != NULL) out << *( GridDefinition*) gridDef << std::endl; 123 135 if(domainDef != NULL) out << *(DomainDefinition*) domainDef << std::endl; 124 136 } … … 128 140 if (_parent != 0) return; 129 141 // Résolution des héritages descendants pour chacun des groupes de définitions. 130 if( fieldDef != NULL) fieldDef->solveDescInheritance();131 if( fileDef != NULL) fileDef->solveDescInheritance();132 if( axisDef != NULL) axisDef->solveDescInheritance();133 if( gridDef != NULL) gridDef->solveDescInheritance();142 if( fieldDef != NULL) fieldDef->solveDescInheritance(); 143 if( fileDef != NULL) fileDef->solveDescInheritance(); 144 if( axisDef != NULL) axisDef->solveDescInheritance(); 145 if( gridDef != NULL) gridDef->solveDescInheritance(); 134 146 if(domainDef != NULL) domainDef->solveDescInheritance(); 135 147 } … … 176 188 Poco::HashMap<string, StrHashMap<Context> >::Iterator it; 177 189 178 for ( it = AllListContext.begin(); it != AllListContext.end(); it++) 190 for ( it = AllListContext.begin(); 191 it != AllListContext.end(); it++) 179 192 { 180 193 // Résolution des héritages descendants (cà d des héritages de groupes) pour chacun des contextes. … … 192 205 193 206 static bool HasContext(const string& id) 194 { 195 Poco::HashMap<string, StrHashMap<Context> > &AllListContext = Context::GetAllListObject(); 196 return (AllListContext.find(id) != AllListContext.end()); 197 } 207 { return (Context::GetAllListObject().find(id) != Context::GetAllListObject().end()); } 198 208 199 209 static Context* GetContext(const string& id) 200 210 { return (Context::GetAllListObject()[id][id]); } 201 211 212 static const std::stack<string>& GetStackContextId(void) 213 { return (Context::Stid); } 214 215 static Context* GetCurrentContext(void) 216 { return (Context::GetObject(Context::GetCurrentContextId())); } 217 202 218 static Context* SwapContext(void) 203 219 { … … 210 226 return (Context::GetObject(lastId)); 211 227 } 212 213 static const std::stack<string>& GetStackContextId(void)214 { return (Context::Stid); }215 216 static Context* GetCurrentContext(void)217 { return (Context::GetObject(Context::GetCurrentContextId())); }218 228 219 229 static void SetCurrentContext(const string& id, bool withSwap = false, bool withcheck = true) … … 248 258 static std::stack<string> Stid; 249 259 260 DataTreatment * dtreatment; 250 261 AbstractCalendar * ccalendar; 251 262 252 FieldDefinition* fieldDef;253 FileDefinition* fileDef;254 AxisDefinition* axisDef;255 GridDefinition* gridDef;263 FieldDefinition * fieldDef; 264 FileDefinition * fileDef; 265 AxisDefinition * axisDef; 266 GridDefinition * gridDef; 256 267 DomainDefinition * domainDef; 257 268
Note: See TracChangeset
for help on using the changeset viewer.