Changeset 990

Show
Ignore:
Timestamp:
10/29/08 18:54:45 (2 months ago)
Author:
dutka
Message:

Improved recompilation process.
Changed Xerces-C XML toolkit for libxml2 in WrapperFile class.
Removed useless files.
Improved WrapperData class and some utility classes.
Improved StorageManager class.
Improved XMLStorageManager class.
Add XMLToolbox.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gui/src/Makefile.am

    r842 r990  
    3434qopenturns_CPPFLAGS += $(AM_CPPFLAGS) 
    3535qopenturns_CXXFLAGS  = $(AM_CXXFLAGS) 
     36qopenturns_CXXFLAGS += $(QT_CXXFLAGS) 
    3637qopenturns_LDADD     = $(OPENTURNS_LIBS) 
     38qopenturns_LDADD    += $(QT_LIBS) 
    3739qopenturns_SOURCES   = \ 
    3840        main.cxx \ 
  • trunk/lib/configure.ac

    r966 r990  
    118118 
    119119# Detect XercesC configuration 
    120 OT_CHECK_XERCESC 
     120#OT_CHECK_XERCESC 
     121 
     122# Detect libxml2 configuration 
     123OT_CHECK_LIBXML2 
    121124 
    122125# Detect regex library 
     
    150153 
    151154# Check for Qt 
    152 OT_CHECK_QT 
     155#OT_CHECK_QT 
    153156 
    154157# This definition is put here not to disturb the normal process 
     
    322325 
    323326test "x$WITH_R" = x1         && sum_r=OK         || sum_r="no * (MANDATORY)" 
    324 test "x$WITH_XERCESC" = x1   && sum_xercesc=OK   || sum_xercesc="no * (MANDATORY)" 
     327#test "x$WITH_XERCESC" = x1   && sum_xercesc=OK   || sum_xercesc="no * (MANDATORY)" 
     328test "x$WITH_LIBXML2" = x1   && sum_libxml2=OK   || sum_xercesc="no * (MANDATORY)" 
    325329test "x$WITH_REGEX" = x1     && sum_regex=OK     || sum_regex="no * (MANDATORY)" 
    326330test "x$WITH_BC" = x1        && sum_bc=OK        || sum_bc="no * (optional)" 
     
    330334test "x$WITH_BOOST" = x1     && sum_boost=OK     || sum_boost="no * (MANDATORY)" 
    331335test "x$WITH_THREADS" = x1   && sum_threads=OK   || sum_threads="no (useless)" 
    332 test "x$have_qt" = xyes      && sum_qt=OK        || sum_qt="no * (MANDATORY)" 
     336#test "x$have_qt" = xyes      && sum_qt=OK        || sum_qt="no * (MANDATORY)" 
    333337 
    334338cat <<EOT > summary 
     
    343347 ----------------------------- 
    344348  R                    ${sum_r} 
    345   Xerces               ${sum_xercesc
     349  libxml2              ${sum_libxml2
    346350  Regex                ${sum_regex} 
    347351  Doxygen              ${sum_doxygen} 
     
    351355  BOOST                ${sum_boost} 
    352356  Multithreading       ${sum_threads} 
    353   Qt                   ${sum_qt} 
    354357EOT 
    355358cat summary 
  • trunk/lib/include/Makefile.am

    r631 r990  
    3636        OTtypes.hxx \ 
    3737        OTtestcode.hxx 
     38 
     39BUILT_SOURCES = OTconfigureArgs.hxx 
     40 
     41OTconfigure_args-stamp : OTconfigure_args.hxx 
     42OTconfigureArgs.hxx: OTconfigure_args-stamp 
     43        cmp -s OTconfigure_args.hxx OTconfigureArgs.hxx || cp OTconfigure_args.hxx OTconfigureArgs.hxx 
     44        echo > $< 
  • trunk/lib/include/OTconfig.h.in

    r941 r990  
    1919 
    2020/* Support for regular expression library */ 
     21#undef HAS_LIBXML2 
     22 
     23/* Support for regular expression library */ 
    2124#undef HAS_REGEX 
    22  
    23 /* Support for Xerces-C XML library */ 
    24 #undef HAS_XERCESC 
    2525 
    2626/* Define to 1 if you have the `alarm' function. */ 
     
    5656/* Define if you have LAPACK library. */ 
    5757#undef HAVE_LAPACK 
     58 
     59/* Define to 1 if you have the <libxml/parser.h> header file. */ 
     60#undef HAVE_LIBXML_PARSER_H 
    5861 
    5962/* Define to 1 if your system has a GNU libc compatible `malloc' function, and 
     
    124127#undef HAVE_UNISTD_H 
    125128 
    126 /* Define to 1 if you have the <xercesc/dom/DOM.hpp> header file. */ 
    127 #undef HAVE_XERCESC_DOM_DOM_HPP 
    128  
    129 /* Define to 1 if you have the <xercesc/framework/StdOutFormatTarget.hpp> 
    130    header file. */ 
    131 #undef HAVE_XERCESC_FRAMEWORK_STDOUTFORMATTARGET_HPP 
    132  
    133 /* Define to 1 if you have the <xercesc/parsers/XercesDOMParser.hpp> header 
    134    file. */ 
    135 #undef HAVE_XERCESC_PARSERS_XERCESDOMPARSER_HPP 
    136  
    137 /* Define to 1 if you have the <xercesc/util/PlatformUtils.hpp> header file. 
    138    */ 
    139 #undef HAVE_XERCESC_UTIL_PLATFORMUTILS_HPP 
    140  
    141 /* Define to 1 if you have the <xercesc/util/XercesVersion.hpp> header file. 
    142    */ 
    143 #undef HAVE_XERCESC_UTIL_XERCESVERSION_HPP 
    144  
    145129/* Define to 1 if the system has the type `_Bool'. */ 
    146130#undef HAVE__BOOL 
     
    189173#undef VERSION 
    190174 
    191 /* Define to 1 if the X Window System is missing or not being used. */ 
    192 #undef X_DISPLAY_MISSING 
    193  
    194175/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a 
    195176   `char[]'. */ 
  • trunk/lib/include/OTdebug.h

    r941 r990  
    3131                     + __GNUC_MINOR__ * 100           \ 
    3232                     + __GNUC_PATCHLEVEL__) 
     33 
     34#if GCC_VERSION <= 30406 /* GCC 3.4.6 and below */ 
     35#define REINTERPRET_CAST(T,V) ( (T) (V) ) 
     36#else /* GCC after 3.4.6 */ 
     37#define REINTERPRET_CAST(T,V) ( reinterpret_cast< T > (V) ) 
     38#endif 
    3339 
    3440#define DEPRECATED  __attribute__ ((deprecated)) 
  • trunk/lib/m4/examples/Makefile.am

    r966 r990  
    2525bin_PROGRAMS =  
    2626AM_CPPFLAGS  = $(OPENTURNS_CPPFLAGS) $(BOOST_CPPFLAGS) 
    27 AM_CXXFLAGS  = $(QT_CXXFLAGS) 
    2827AM_LDFLAGS   = $(OPENTURNS_LDFLAGS) 
    2928LDADD        = $(OPENTURNS_LIBS) 
  • trunk/lib/src/Base/Common/Catalog.cxx

    r862 r990  
    9898        if (catalog_.find(factoryName) == catalog_.end()) { 
    9999          catalog_[factoryName] = p_factory->clone(); 
    100           //Log::Debug(OSS() << "Adding factory of " << factoryName << " to Catalog"); 
     100          Log::Debug(OSS() << "Adding factory of " << factoryName << " to Catalog"); 
    101101        } 
    102102      } 
  • trunk/lib/src/Base/Common/Exception.cxx

    r941 r990  
    4646        : names_() 
    4747      { 
    48         // Log::Debug("ExceptionNames ctor"); 
     48        Log::Debug("ExceptionNames ctor"); 
    4949         
    5050        // Registration of destructor at exit 
    51         /* int rc = */ 
    52         std::atexit(ExceptionNames::release); 
     51        int rc = std::atexit(ExceptionNames::release); 
    5352 
    54         // Log::Debug(OSS() << "ExceptionNames registration of destructor = " << (rc ? "ERROR" : "OK") ); 
     53        Log::Debug(OSS() << "ExceptionNames registration of destructor = " << (rc ? "ERROR" : "OK") ); 
    5554 
    5655        std::vector<String> & ref_names_ = *static_cast<std::vector<String> *>(&names_); 
  • trunk/lib/src/Base/Common/Log.cxx

    r941 r990  
    166166 
    167167 
    168       /* Set the severity flags for the messages logged to the file */ 
     168      /* Get/Set the severity flags for the messages logged to the file */ 
    169169      void Log::Show(Severity flags) 
    170170      { 
     
    172172      } 
    173173 
    174  
    175        
     174      Log::Severity Log::Flags() 
     175      { 
     176        return Log::Severity_; 
     177      } 
     178 
     179      
    176180      /* Append an entry at the end of the list */ 
    177181      void Log::push(const Entry & entry) 
  • trunk/lib/src/Base/Common/Log.hxx

    r941 r990  
    7474        static void SetFile(const FileName & file); 
    7575 
    76         /* Set the severity flags for the messages logged to the file */ 
     76        /* Get/Set the severity flags for the messages logged to the file */ 
    7777        static void Show(Severity flags); 
     78        static Severity Flags(); 
    7879 
    7980 
  • trunk/lib/src/Base/Common/Makefile.am

    r974 r990  
    4747        Thread.hxx \ 
    4848        StorageManager.hxx \ 
    49         XMLStorageManager.hxx \ 
    5049        WrapperInterface.h \ 
    5150        Path.hxx \ 
     
    6867 
    6968noinst_LTLIBRARIES       = libOTCommon.la 
    70 libOTCommon_la_CXXFLAGS  = $(AM_CXXFLAGS) $(QT_CXXFLAGS) 
     69libOTCommon_la_CXXFLAGS  = $(AM_CXXFLAGS) 
    7170libOTCommon_la_LDFLAGS   = -no-undefined 
    72 libOTCommon_la_LIBADD    = $(QT_LIBS) 
     71libOTCommon_la_LIBADD    = 
    7372libOTCommon_la_SOURCES   = \ 
    7473        OSS.cxx \ 
     
    8786        Thread.cxx \ 
    8887        StorageManager.cxx \ 
    89         XMLStorageManager.cxx \ 
    9088        Path.cxx \ 
    9189        ComparisonOperator.cxx \ 
     
    104102 
    105103 
    106  
    107  
    108 #pkglib_LTLIBRARIES        = libOTwrapper.la 
    109 #libOTwrapper_la_CXXFLAGS  = $(AM_CXXFLAGS) $(QT_CXXFLAGS) 
    110 #libOTwrapper_la_CXXFLAGS += -I@regex_include_path@  
    111 #libOTwrapper_la_LDFLAGS   = -no-undefined -version-info 0:0:0 
    112 #libOTwrapper_la_LDFLAGS  += -L@regex_lib_path@ 
    113 #libOTwrapper_la_LIBADD    = -l@regex_lib_name@ 
    114 #libOTwrapper_la_SOURCES   = \ 
    115 #       WrapperCommon.cxx \ 
    116 #       WrapperCommonFunctions.cxx \ 
    117 #       PlatformInfo.cxx \ 
    118 #       Log.cxx \ 
    119 #       OSS.cxx 
    120  
    121  
     104if WITH_LIBXML2 
     105AM_CPPFLAGS            += -I$(libxml2_include_path) 
     106libOTCommon_la_LDFLAGS += -L$(libxml2_lib_path) 
     107libOTCommon_la_LIBADD  += -l$(libxml2_lib_name) 
     108otinclude_HEADERS += \ 
     109        XMLStorageManager.hxx \ 
     110        XMLToolbox.hxx 
     111libOTCommon_la_SOURCES  += \ 
     112        XMLStorageManager.cxx \ 
     113        XMLToolbox.cxx 
     114endif 
  • trunk/lib/src/Base/Common/PersistentObject.hxx

    r818 r990  
    152152        { 
    153153          if (! mgr.isSavedObject(id_)) { 
    154             StorageManager::Advocate adv = mgr.registerObject(*this, fromStudy); 
     154            StorageManager::Advocate adv ( mgr.registerObject(*this, fromStudy) ); 
    155155            save(adv); 
    156156            mgr.markObjectAsSaved(id_); 
  • trunk/lib/src/Base/Common/PersistentObjectFactory.hxx

    r862 r990  
    103103        virtual PersistentObject * build(const StorageManager & mgr) const 
    104104        { 
    105           StorageManager::Advocate adv = mgr.readObject(); 
     105          StorageManager::Advocate adv ( mgr.readObject() ); 
    106106           
    107107          PERSISTENT * p_rebuildObject = new PERSISTENT(); 
  • trunk/lib/src/Base/Common/PlatformInfo.cxx

    r508 r990  
    2525 */ 
    2626#include "OTconfig.hxx" 
    27 #include "OTconfigure_args.hxx" 
     27#include "OTconfigureArgs.hxx" 
    2828#include "OSS.hxx" 
    2929#include "PlatformInfo.hxx" 
  • trunk/lib/src/Base/Common/ResourceMap.cxx

    r966 r990  
    2424 *  Id:      $Id$ 
    2525 */ 
    26 #include <qfile.h>                  // for QFile qtextstream.h 
    27 #include <qtextstream.h>            // for QTextStream 
    2826#include <unistd.h>                 // for sysconf 
    2927#include "OSS.hxx" 
     
    3230#include "Path.hxx" 
    3331#include "Log.hxx" 
     32#include "XMLToolbox.hxx" 
    3433 
    3534#ifndef R_EXECUTABLE_PATH 
     
    3736#endif 
    3837 
     38#ifndef XML_SUPPORTED 
     39#error "XML support is mandatory. Check configuration." 
     40#endif 
     41 
    3942namespace OpenTURNS 
    4043{ 
     
    4548    namespace Common 
    4649    { 
    47       const String ConfigurationFileName = "openturns.conf"; 
    48       const String RootElementName = "openturns-configuration"; 
     50 
     51      static const char * ConfigurationFileName = "openturns.conf"; 
     52      static const char * RootElementName = "openturns-configuration"; 
     53      static const char * XMLTag_value = "value"; 
     54      static const char * XMLAttr_undefined = "undefined"; 
    4955 
    5056      Pointer<ResourceMap> ResourceMap::P_instance_; 
     
    103109      } 
    104110 
     111#if defined HAS_LIBXML2 
     112 
    105113      /* Update the ResourceMap with information from the configuration file */ 
    106114      void ResourceMap::readConfigurationFile(const FileName & configurationFile) 
     
    109117 
    110118        // Open the configuration file and load it in a DOM document for later analysis 
    111         QDomDocument document = parseConfigurationFile(configurationFile); 
    112  
    113         if( document.documentElement().tagName() != RootElementName ) 
    114           throw ConfigurationFileParsingException(HERE) << "Can NOT find root element '" << RootElementName << "' in file '" << configurationFile << "'"; 
    115         // Version information is not used yet : 
    116         //      UnsignedLong version = 0; 
    117         //      String stul = document_.documentElement().attribute("version", ""); 
    118         //      std::istringstream iss (stul); 
    119         //      iss >> version; 
    120          
    121  
     119        XMLDoc document( configurationFile ); 
     120 
     121        // Check it is an OpenTURNS' one 
     122        xmlNodePtr rootElt = xmlDocGetRootElement( document ); 
     123        if (rootElt == NULL) throw ConfigurationFileParsingException(HERE) << "Wrapper file has no root element" << configurationFile; 
     124        if (xmlStrcmp( rootElt->name, REINTERPRET_CAST(const xmlChar *, RootElementName) )) 
     125          throw ConfigurationFileParsingException(HERE) << "Wrapper file " << configurationFile 
     126                                                  << " has an invalid root element (" << rootElt->name << ")" 
     127                                                  << " at line " << xmlGetLineNo(rootElt); 
    122128 
    123129 
    124130        // Walk through the DOM document to read the data 
    125         QDomNode node = document.documentElement().firstChild(); 
    126         while( !node.isNull() ) { 
    127           QDomElement element = node.toElement(); 
    128           if( !element.isNull() ) { 
    129             String key   = element.tagName(); 
    130             String value = element.attribute("value","undefined"); 
    131             std::map<String,String>::operator[](key) = value; 
     131        if (rootElt && rootElt->children) { 
     132          for (xmlNodePtr current = rootElt->children; current; current = current->next) { 
     133            if (XML::IsElement(current)) { 
     134              String key = XML::ToString(current->name); 
     135              String value = XML::GetAttributeByName( current, XMLTag_value ); 
     136              if (value.empty()) value = XMLAttr_undefined; 
     137              std::map<String,String>::operator[](key) = value; 
     138            } 
    132139          } 
    133           node = node.nextSibling(); 
    134140        } 
    135          
    136       } 
    137  
    138       /* Parse the configuration file */ 
    139       QDomDocument ResourceMap::parseConfigurationFile(const FileName & configurationFile) const 
    140       { 
    141         QDomDocument document = QDomDocument(configurationFile); 
    142         QFile file(configurationFile); 
    143         if( !file.open( IO_ReadOnly ) ) 
    144           throw FileOpenException(HERE) << "Can NOT open file '" << configurationFile << "' for reading"; 
    145            
    146         if( !document.setContent( &file ) ) { 
    147           file.close(); 
    148           throw FileOpenException(HERE) << "Can NOT parse file '" << configurationFile << "'"; 
    149         } 
    150         file.close(); 
    151  
    152         return document; 
    153       } 
     141 
     142      } 
     143 
     144#else 
     145      /* Update the ResourceMap with information from the configuration file */ 
     146      void ResourceMap::readConfigurationFile(const FileName & configurationFile) 
     147      { 
     148        throw NotYetImplemented(HERE) << "ResourceMap only support libxml2"; 
     149      } 
     150 
     151#endif 
    154152 
    155153      /* Find the configuration file in specific path (see Path class for algorithm) */ 
  • trunk/lib/src/Base/Common/ResourceMap.hxx

    r815 r990  
    2828 
    2929#include <map> 
    30 #include <qdom.h> 
    3130#include "Pointer.hxx" 
    3231 
     
    9493        void readConfigurationFile(const FileName & configurationFile); 
    9594 
    96         /** Parse the configuration file */ 
    97         QDomDocument parseConfigurationFile(const FileName & configurationFile) const; 
    98  
    9995        /** Find the configuration file in specific path (see Path class for algorithm) */ 
    10096        FileName findConfigurationFile() const; 
  • trunk/lib/src/Base/Common/StorageManager.cxx

    r818 r990  
    4242 
    4343 
    44       StorageManager::Advocate::Advocate(const AdvocateImplementation & implementation) 
    45         : p_implementation_(implementation.clone()
     44      StorageManager::Advocate::Advocate(const Implementation & p_implementation) 
     45        : p_implementation_(p_implementation
    4646      { 
    4747        // Nothing to do 
     
    253253      } 
    254254 
    255       void StorageManager::Advocate::readValue(InterfaceObject & obj) const 
    256       { 
    257         p_implementation_->readValue(obj); 
    258       } 
    259  
    260255      void StorageManager::Advocate::readValue(InterfaceObject & obj, AttributeName attribute, const String & st) const 
    261256      { 
     
    263258      } 
    264259 
    265       void StorageManager::Advocate::readValue(PersistentObject & obj) const 
    266       { 
    267         p_implementation_->readValue(obj); 
    268       } 
    269  
    270260      void StorageManager::Advocate::readValue(PersistentObject & obj, AttributeName attribute, const String & st) const 
    271261      { 
    272262        p_implementation_->readValue(obj, attribute, st); 
    273       } 
    274  
    275       void StorageManager::Advocate::firstValueToRead() const 
    276       { 
    277         p_implementation_->firstValueToRead(); 
    278       } 
    279  
    280       Bool StorageManager::Advocate::moreValuesToRead() const 
    281       { 
    282         return p_implementation_->moreValuesToRead(); 
    283       } 
    284  
    285       void StorageManager::Advocate::nextValueToRead() const 
    286       { 
    287         p_implementation_->nextValueToRead(); 
    288263      } 
    289264 
     
    519494      } 
    520495 
    521       void StorageManager::AdvocateImplementation::readValue(InterfaceObject & obj) const 
    522       { 
    523         p_manager_->readValue(obj); 
    524       } 
    525  
    526496      void StorageManager::AdvocateImplementation::readValue(InterfaceObject & obj, AttributeName attribute, const String & st) const 
    527497      { 
     
    529499      } 
    530500 
    531       void StorageManager::AdvocateImplementation::readValue(PersistentObject & obj) const 
    532       { 
    533         p_manager_->readValue(obj); 
    534       } 
    535  
    536501      void StorageManager::AdvocateImplementation::readValue(PersistentObject & obj, AttributeName attribute, const String & st) const 
    537502      { 
    538503        p_manager_->readValue(obj, attribute, st); 
    539504      } 
    540  
    541       void StorageManager::AdvocateImplementation::firstValueToRead() const 
    542       { 
    543         p_manager_->firstValueToRead(); 
    544       } 
    545  
    546       Bool StorageManager::AdvocateImplementation::moreValuesToRead() const 
    547       { 
    548         return p_manager_->moreValuesToRead(); 
    549       } 
    550  
    551       void StorageManager::AdvocateImplementation::nextValueToRead() const 
    552       { 
    553         p_manager_->nextValueToRead(); 
    554       } 
    555  
    556505 
    557506 
     
    761710       * This method build a new advocate to talk to the storage manager 
    762711       */ 
    763       StorageManager::WriteAdvocateImplementation StorageManager::registerObject(const PersistentObject & obj, bool fromStudy) const 
    764       { 
    765         return WriteAdvocateImplementation(const_cast<StorageManager *>(this), obj, fromStudy); 
     712      Pointer<StorageManager::WriteAdvocateImplementation> StorageManager::registerObject(const PersistentObject & obj, bool fromStudy) const 
     713      { 
     714        return new WriteAdvocateImplementation(const_cast<StorageManager *>(this), obj, fromStudy); 
    766715      } 
    767716 
     
    771720       * This method build a new advocate to talk to the storage manager 
    772721       */ 
    773       StorageManager::ReadAdvocateImplementation StorageManager::readObject() const 
    774       { 
    775         return ReadAdvocateImplementation(const_cast<StorageManager *>(this)); 
     722      Pointer<StorageManager::ReadAdvocateImplementation> StorageManager::readObject() const 
     723      { 
     724        return new ReadAdvocateImplementation(const_cast<StorageManager *>(this)); 
    776725      } 
    777726 
     
    988937      } 
    989938 
    990       void StorageManager::readValue(InterfaceObject & obj) 
    991       { 
    992         throw NotDefinedException(HERE); 
    993       } 
    994  
    995939      void StorageManager::readValue(InterfaceObject & obj, AttributeName attribute, const String & st) 
    996940      { 
     
    998942      } 
    999943 
    1000       void StorageManager::readValue(PersistentObject & obj) 
    1001       { 
    1002         throw NotDefinedException(HERE); 
    1003       } 
    1004  
    1005944      void StorageManager::readValue(PersistentObject & obj, AttributeName attribute, const String & st) 
    1006945      { 
    1007946        throw NotDefinedException(HERE); 
    1008947      } 
    1009  
    1010       void StorageManager::firstValueToRead() 
    1011       { 
    1012         throw NotDefinedException(HERE); 
    1013       } 
    1014  
    1015       Bool StorageManager::moreValuesToRead() 
    1016       { 
    1017         throw NotDefinedException(HERE); 
    1018         return false; 
    1019       } 
    1020  
    1021       void StorageManager::nextValueToRead() 
    1022       { 
    1023         throw NotDefinedException(HERE); 
    1024       } 
    1025  
    1026948 
    1027949 
  • trunk/lib/src/Base/Common/StorageManager.hxx

    r877 r990  
    201201          void readAttribute(AttributeName attribute, UnsignedLong & ul) const; 
    202202 
    203           void firstValueToRead() const; 
    204           Bool moreValuesToRead() const; 
    205           void nextValueToRead() const; 
    206203          // template <class T> void readValue(UnsignedLong & index, T & value) const 
    207204          // { return p_manager_->readValue(index,value); } 
     
    220217          void readValue(String & name, UnsignedLong & value) const; 
    221218          void readValue(String & name, Bool & value) const; 
    222           void readValue(InterfaceObject & obj) const; 
    223219          void readValue(InterfaceObject & obj, AttributeName attribute, const String & st) const; 
    224           void readValue(PersistentObject & obj) const; 
    225220          void readValue(PersistentObject & obj, AttributeName attribute, const String & st) const; 
    226221 
     
    266261         * This method build a new advocate to talk to the storage manager 
    267262         */ 
    268         WriteAdvocateImplementation registerObject(const PersistentObject & obj, bool fromStudy = false) const; 
     263        Pointer<WriteAdvocateImplementation> registerObject(const PersistentObject & obj, bool fromStudy = false) const; 
    269264 
    270265        /** 
    271266         * This method build a new advocate to talk to the storage manager 
    272267         */ 
    273         ReadAdvocateImplementation readObject() const; 
     268        Pointer<ReadAdvocateImplementation> readObject() const; 
    274269 
    275270 
     
    279274        { 
    280275        public: 
    281           Advocate(const AdvocateImplementation & implementation); 
     276          typedef Pointer<AdvocateImplementation> Implementation; 
     277 
     278          Advocate(const Implementation & p_implementation); 
    282279          virtual ~Advocate(); 
    283280 
     
    316313          void readAttribute(AttributeName attribute, UnsignedLong & ul) const; 
    317314 
    318           void firstValueToRead() const; 
    319           Bool moreValuesToRead() const; 
    320           void nextValueToRead() const; 
    321315          // template <class T> void readValue(UnsignedLong & index, T & value) const 
    322316          // { return p_implementation_->readValue(index,value); } 
     
    335329          void readValue(String & name, UnsignedLong & value) const; 
    336330          void readValue(String & name, Bool & value) const; 
    337           void readValue(InterfaceObject & obj) const; 
    338331          void readValue(InterfaceObject & obj, AttributeName attribute, const String & st) const; 
    339           void readValue(PersistentObject & obj) const; 
    340332          void readValue(PersistentObject & obj, AttributeName attribute, const String & st) const; 
    341333 
    342334        private: 
    343           Pointer<AdvocateImplementation> p_implementation_; 
     335          Implementation p_implementation_; 
    344336 
    345337        }; /* end class Advocate */ 
     
    461453        virtual void readAttribute(AttributeName attribute, UnsignedLong & ul); 
    462454 
    463         virtual void firstValueToRead(); 
    464         virtual Bool moreValuesToRead(); 
    465         virtual void nextValueToRead(); 
    466455        // template <class T> void readValue(UnsignedLong & index, T & value) const 
    467456        // { throw NotDefinedException(HERE); } 
     
    480469        virtual void readValue(String & name, UnsignedLong & value); 
    481470        virtual void readValue(String & name, Bool & value); 
    482         virtual void readValue(InterfaceObject & obj); 
    483471        virtual void readValue(InterfaceObject & obj, AttributeName attribute, const String & st); 
    484         virtual void readValue(PersistentObject & obj); 
    485472        virtual void readValue(PersistentObject & obj, AttributeName attribute, const String & st); 
    486473 
  • trunk/lib/src/Base/Common/XMLStorageManager.cxx

    r862 r990  
    2424 *  Id:      $Id$ 
    2525 */ 
    26 #include <qfile.h>                  // for QFile qtextstream.h 
    27 #include <qtextstream.h>            // for QTextSream 
    2826#include "XMLStorageManager.hxx" 
    29 //#include "StringXMLConverter.hxx" 
    3027#include "PersistentObject.hxx" 
    3128#include "InterfaceObject.hxx" 
     
    3431#include "Study.hxx" 
    3532#include "OSS.hxx" 
    36  
     33#include "Log.hxx" 
    3734 
    3835 
     
    4643    { 
    4744 
    48       const String RootElementName = "openturns-study"; 
     45      static const char * RootElementName = "openturns-study"; 
    4946 
    5047      XMLStorageManager::XMLList::XMLList(const XMLStorageManager & mgr, State state, EntityName entity) 
    51         : nodeList_(state.current_.elementsByTagName(mgr.getEntityString(entity))), 
     48        : nodeList_(XML::GetFirstChild(state.current_)), 
    5249          cursor_(0), 
    53           manager_(mgr) 
    54       { 
    55         // Nothing to do 
     50          manager_(mgr), 
     51          length_(0), 
     52          entity_(entity) 
     53      { 
     54        // we count the number of children 
     55        for (XML::Node cur = nodeList_; cur; cur = XML::GetNextNode(cur)) 
     56          if (XML::IsElement(cur, manager_.getEntityString(entity_))) ++length_; 
    5657      } 
    5758 
     
    6364      UnsignedLong XMLStorageManager::XMLList::getSize() const 
    6465      { 
    65         return nodeList_.length()
     66        return length_
    6667      } 
    6768 
    6869      void XMLStorageManager::XMLList::firstValueToRead() 
    6970      { 
    70         cursor_ = 0; 
     71        for( cursor_ = nodeList_; cursor_; cursor_ = XML::GetNextNode(cursor_) ) 
     72          if (XML::IsElement(cursor_, manager_.getEntityString(entity_))) break; 
    7173      } 
    7274 
    7375      Bool XMLStorageManager::XMLList::moreValuesToRead() 
    7476      { 
    75         return (cursor_ < nodeList_.length()); 
     77        return (cursor_ != NULL); 
    7678      } 
    7779 
    7880      void XMLStorageManager::XMLList::nextValueToRead() 
    7981      { 
    80         ++cursor_; 
     82        while ( (cursor_ = XML::GetNextNode(cursor_)) != NULL ) 
     83          if (XML::IsElement(cursor_, manager_.getEntityString(entity_))) break; 
    8184      } 
    8285 
    8386      Bool XMLStorageManager::XMLList::readValue(UnsignedLong & index, NumericalScalar & value) 
    8487      { 
    85         QDomElement element = nodeList_.item(cursor_).toElement(); 
    86         Bool result = (element.tagName() == manager_.getEntityString(NumericalScalarEntity)) 
    87           && element.hasAttribute(manager_.getAttributeString(IndexAttribute)); 
    88         if (result) { 
    89           { 
    90             String stidx = element.attribute(manager_.getAttributeString(IndexAttribute), ""); 
     88        Bool result = XML::IsElement(cursor_, manager_.getEntityString(NumericalScalarEntity)) 
     89          && XML::ElementHasAttribute(cursor_, manager_.getAttributeString(IndexAttribute)); 
     90        if (result) { 
     91          { 
     92            String stidx = XML::GetAttributeByName(cursor_, manager_.getAttributeString(IndexAttribute)); 
    9193            std::istringstream iss (stidx); 
    9294            iss >> index; 
    9395          } 
    9496          { 
    95             value = 0; 
    96             QDomNode node = element.firstChild(); 
    97             if (node.isText()) { 
    98               QDomText textNode = node.toText(); 
    99               String stval = textNode.data(); 
    100               std::istringstream iss (stval); 
    101               iss >> value; 
    102             } 
     97            value = 0.; 
     98            String stval = XML::GetNodeValue( cursor_ ); 
     99            std::istringstream iss (stval); 
     100            iss >> value; 
    103101          } 
    104102        } 
     
    108106      Bool XMLStorageManager::XMLList::readValue(UnsignedLong & index, NumericalComplex & value) 
    109107      { 
    110         QDomElement element = nodeList_.item(cursor_).toElement(); 
    111         Bool result = (element.tagName() == manager_.getEntityString(NumericalComplexEntity)) 
    112           && element.hasAttribute(manager_.getAttributeString(IndexAttribute)); 
    113         if (result) { 
    114           { 
    115             String stidx = element.attribute(manager_.getAttributeString(IndexAttribute), ""); 
     108        Bool result = XML::IsElement(cursor_, manager_.getEntityString(NumericalComplexEntity)) 
     109          && XML::ElementHasAttribute(cursor_, manager_.getAttributeString(IndexAttribute)); 
     110        if (result) { 
     111          { 
     112            String stidx = XML::GetAttributeByName(cursor_, manager_.getAttributeString(IndexAttribute)); 
    116113            std::istringstream iss (stidx); 
    117114            iss >> index; 
    118115          } 
    119116          { 
    120             value = 0; 
    121             QDomNode node = element.firstChild(); 
    122             if (node.isText()) { 
    123               QDomText textNode = node.toText(); 
    124               String stval = textNode.data(); 
    125               std::istringstream iss (stval); 
    126               iss >> value; 
    127             } 
     117            value = 0.; 
     118            String stval = XML::GetNodeValue( cursor_ ); 
     119            std::istringstream iss (stval); 
     120            iss >> value; 
    128121          } 
    129122        } 
     
    133126      Bool XMLStorageManager::XMLList::readValue(UnsignedLong & index, InterfaceObject & obj) 
    134127      { 
    135         QDomElement element = nodeList_.item(cursor_).toElement(); 
    136         Bool result = (element.tagName() == manager_.getEntityString(ObjectEntity)) 
    137           && element.hasAttribute(manager_.getAttributeString(IndexAttribute)); 
    138         if (result) { 
    139           { 
    140             String stidx = element.attribute(manager_.getAttributeString(IndexAttribute), ""); 
     128        Bool result = XML::IsElement(cursor_, manager_.getEntityString(ObjectEntity)) 
     129          && XML::ElementHasAttribute(cursor_, manager_.getAttributeString(IndexAttribute)); 
     130        if (result) { 
     131          { 
     132            String stidx = XML::GetAttributeByName(cursor_, manager_.getAttributeString(IndexAttribute)); 
    141133            std::istringstream iss (stidx); 
    142134            iss >> index; 
     
    144136          { 
    145137            Id shadowedId; 
    146             String stid = element.attribute(manager_.getAttributeString(IdAttribute), ""); 
     138            String stid = XML::GetAttributeByName(cursor_, manager_.getAttributeString(IdAttribute)); 
    147139            std::istringstream iss (stid); 
    148140            iss >> shadowedId; 
     
    157149      Bool XMLStorageManager::XMLList::readValue(UnsignedLong & index, PersistentObject & obj) 
    158150      { 
    159         QDomElement element = nodeList_.item(cursor_).toElement(); 
    160         Bool result = (element.tagName() == manager_.getEntityString(ObjectEntity)) 
    161           && element.hasAttribute(manager_.getAttributeString(IndexAttribute)); 
    162         if (result) { 
    163           { 
    164             String stidx = element.attribute(manager_.getAttributeString(IndexAttribute), ""); 
     151        Bool result = XML::IsElement(cursor_, manager_.getEntityString(ObjectEntity)) 
     152          && XML::ElementHasAttribute(cursor_, manager_.getAttributeString(IndexAttribute)); 
     153        if (result) { 
     154          { 
     155            String stidx = XML::GetAttributeByName(cursor_, manager_.getAttributeString(IndexAttribute)); 
    165156            std::istringstream iss (stidx); 
    166157            iss >> index; 
     
    168159