Ignore:
Timestamp:
10/07/10 10:29:38 (14 years ago)
Author:
hozdoba
Message:

Amélioration de quelques portions de code.
Ajout de contructeurs par copie.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XMLIO_V2/dev/dev_rv/src/XMLIO/object_template.hpp

    r125 r126  
    2727 
    2828            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            } 
    3137 
    3238            if (c.hasChild()) 
    3339            { 
    34                out << IncIndent  << "<" << c.getName()   << c.printId() << ar << ">" << std::endl; 
     40               out << IncIndent  << "<"  << c.getName()  << c.printId() << ar << ">" << std::endl; 
    3541               c.printChild(out); // << Ecriture des objets enfants ici. 
     42               if (c.hasId() && (c.getName().compare("context") == 0)) 
     43                  out << NIndent << std::endl; 
    3644               out << NIndent    << "</" << c.getName()  << ">" << DecEndl; 
    3745            } 
    38             else out << IncIndent << "<" << c.getName()  << c.printId() << ar << "/>" << DecEndl; 
     46            else 
     47               out << IncIndent << "<" << c.getName()  << c.printId() << ar << "/>" << DecEndl; 
    3948 
    4049            return (out); 
    4150         } 
    4251 
     52         bool isDefinition(void) const 
     53         { 
     54            if (!this->hasId()) return (false); 
     55            return (this->getName().compare(this->getId()) == 0); 
     56         } 
     57 
    4358         string getName(void) const 
    4459         { 
    45             if (hasId()) 
     60            if (this->hasId()) 
    4661               if (T::GetDefName().compare(getId()) == 0) 
    47                   return T::GetDefName(); 
     62                  return (T::GetDefName()); 
    4863            return (T::GetName()); 
    4964         } 
     
    5166         T* getBaseObject(void) const { return (baseObject); } 
    5267 
    53          virtual T* getReference(void) const { return (NULL); } 
    54  
    5568         const vector<T*>& getVectRefObject(void) const { return (refObject); } 
    5669 
    57          bool hasRefObject(void) { return (!refObject.empty()); } 
     70         bool hasRefObject(void) const { return (!refObject.empty()); } 
    5871 
    5972         const T* addRefObject(T* obj) 
    6073         { refObject.push_back (obj); return (obj); } 
    6174 
     75      public : /* virtual */ 
     76 
     77         virtual T* getReference(void) const { return (NULL); } 
    6278         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 
    6686         virtual void resolveRefInheritance (void) 
    6787         { 
     
    89109 
    90110            /// 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 */} 
    93116 
    94117      public : /* static */ 
     
    118141         static bool HasObject(const string& _id) 
    119142         { 
    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); 
    121146            return (ObjectTemplate<T>::AllListObj[CurrContext].hasMappedValue(_id)); 
    122147         } 
     
    125150         static Poco::HashMap<string, StrHashMap<T> >& GetAllListObject(void) { return (AllListObj); } 
    126151 
    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); } 
    133155 
    134156      protected : 
    135157 
    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         } 
    140174 
    141175         XML::XMLNode getNodeIncludedFile(const string& path, const string& _rootName) 
    142176         { 
    143177            ifstream istr( path.c_str() , ifstream::in ); 
    144             return XML::XMLNode::CreateNode(istr, _rootName); 
     178            return (XML::XMLNode::CreateNode(istr, _rootName)); 
    145179         } 
    146180 
     
    151185            { 
    152186               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!"); 
    154189               instance_ptr = (V*)V::CreateObject(did); 
    155190               instance_ptr->parse(_node, parseAttr); 
     
    159194 
    160195      private : 
     196 
    161197         T* baseObject; 
    162          vector<T*> refObject; 
     198         std::vector<T*> refObject; 
     199 
     200      private : /* static */ 
    163201 
    164202         static string CurrContext; 
     
    167205   };// class ObjectTemplate 
    168206 
     207   // Initialisation des variables statiques de la classe ObjectTemplate. 
    169208   template <class T> string ObjectTemplate<T>::CurrContext ; 
    170209   template <class T> Poco::HashMap<string, StrHashMap<T> > ObjectTemplate<T>::AllListObj; 
Note: See TracChangeset for help on using the changeset viewer.