Changeset 990
- Timestamp:
- 10/29/08 18:54:45 (2 months ago)
- Files:
-
- trunk/gui/src/Makefile.am (modified) (1 diff)
- trunk/lib/configure.ac (modified) (6 diffs)
- trunk/lib/include/Makefile.am (modified) (1 diff)
- trunk/lib/include/OTconfig.h.in (modified) (4 diffs)
- trunk/lib/include/OTdebug.h (modified) (1 diff)
- trunk/lib/m4/examples/Makefile.am (modified) (1 diff)
- trunk/lib/m4/ot_check_libxml2.m4 (added)
- trunk/lib/src/Base/Common/Catalog.cxx (modified) (1 diff)
- trunk/lib/src/Base/Common/Exception.cxx (modified) (1 diff)
- trunk/lib/src/Base/Common/Log.cxx (modified) (2 diffs)
- trunk/lib/src/Base/Common/Log.hxx (modified) (1 diff)
- trunk/lib/src/Base/Common/Makefile.am (modified) (4 diffs)
- trunk/lib/src/Base/Common/PersistentObject.hxx (modified) (1 diff)
- trunk/lib/src/Base/Common/PersistentObjectFactory.hxx (modified) (1 diff)
- trunk/lib/src/Base/Common/PlatformInfo.cxx (modified) (1 diff)
- trunk/lib/src/Base/Common/ResourceMap.cxx (modified) (6 diffs)
- trunk/lib/src/Base/Common/ResourceMap.hxx (modified) (2 diffs)
- trunk/lib/src/Base/Common/StorageManager.cxx (modified) (9 diffs)
- trunk/lib/src/Base/Common/StorageManager.hxx (modified) (8 diffs)
- trunk/lib/src/Base/Common/XMLStorageManager.cxx (modified) (51 diffs)
- trunk/lib/src/Base/Common/XMLStorageManager.hxx (modified) (6 diffs)
- trunk/lib/src/Base/Common/XMLToolbox.cxx (added)
- trunk/lib/src/Base/Common/XMLToolbox.hxx (added)
- trunk/lib/src/Base/Func/ComputedNumericalMathEvaluationImplementation.cxx (modified) (1 diff)
- trunk/lib/src/Base/Func/ComputedNumericalMathGradientImplementation.cxx (modified) (1 diff)
- trunk/lib/src/Base/Func/ComputedNumericalMathHessianImplementation.cxx (modified) (1 diff)
- trunk/lib/src/Base/Func/Makefile.am (modified) (2 diffs)
- trunk/lib/src/Base/Func/StringXMLConverter.hxx (deleted)
- trunk/lib/src/Base/Func/WrapperData.cxx (modified) (5 diffs)
- trunk/lib/src/Base/Func/WrapperData.hxx (modified) (6 diffs)
- trunk/lib/src/Base/Func/WrapperFile.cxx (modified) (8 diffs)
- trunk/lib/src/Base/Func/WrapperFile.hxx (modified) (4 diffs)
- trunk/lib/src/Base/Func/WrapperObject.cxx (modified) (1 diff)
- trunk/lib/src/Base/Func/XMLStringConverter.hxx (deleted)
- trunk/lib/src/Base/Func/XMLWrapperErrorHandler.cxx (deleted)
- trunk/lib/src/Base/Func/XMLWrapperErrorHandler.hxx (deleted)
- trunk/lib/src/Base/Graph/Makefile.am (modified) (1 diff)
- trunk/lib/src/Base/Stat/Makefile.am (modified) (1 diff)
- trunk/lib/src/Base/Type/Makefile.am (modified) (1 diff)
- trunk/lib/src/Uncertainty/Model/Makefile.am (modified) (1 diff)
- trunk/lib/src/Uncertainty/StatTests/Makefile.am (modified) (1 diff)
- trunk/lib/test/Makefile.am (modified) (2 diffs)
- trunk/python/configure.ac (modified) (4 diffs)
- trunk/python/m4/ot_check_libxml2.m4 (added)
- trunk/python/src/Makefile.am (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/gui/src/Makefile.am
r842 r990 34 34 qopenturns_CPPFLAGS += $(AM_CPPFLAGS) 35 35 qopenturns_CXXFLAGS = $(AM_CXXFLAGS) 36 qopenturns_CXXFLAGS += $(QT_CXXFLAGS) 36 37 qopenturns_LDADD = $(OPENTURNS_LIBS) 38 qopenturns_LDADD += $(QT_LIBS) 37 39 qopenturns_SOURCES = \ 38 40 main.cxx \ trunk/lib/configure.ac
r966 r990 118 118 119 119 # Detect XercesC configuration 120 OT_CHECK_XERCESC 120 #OT_CHECK_XERCESC 121 122 # Detect libxml2 configuration 123 OT_CHECK_LIBXML2 121 124 122 125 # Detect regex library … … 150 153 151 154 # Check for Qt 152 OT_CHECK_QT155 #OT_CHECK_QT 153 156 154 157 # This definition is put here not to disturb the normal process … … 322 325 323 326 test "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)" 328 test "x$WITH_LIBXML2" = x1 && sum_libxml2=OK || sum_xercesc="no * (MANDATORY)" 325 329 test "x$WITH_REGEX" = x1 && sum_regex=OK || sum_regex="no * (MANDATORY)" 326 330 test "x$WITH_BC" = x1 && sum_bc=OK || sum_bc="no * (optional)" … … 330 334 test "x$WITH_BOOST" = x1 && sum_boost=OK || sum_boost="no * (MANDATORY)" 331 335 test "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)" 333 337 334 338 cat <<EOT > summary … … 343 347 ----------------------------- 344 348 R ${sum_r} 345 Xerces ${sum_xercesc}349 libxml2 ${sum_libxml2} 346 350 Regex ${sum_regex} 347 351 Doxygen ${sum_doxygen} … … 351 355 BOOST ${sum_boost} 352 356 Multithreading ${sum_threads} 353 Qt ${sum_qt}354 357 EOT 355 358 cat summary trunk/lib/include/Makefile.am
r631 r990 36 36 OTtypes.hxx \ 37 37 OTtestcode.hxx 38 39 BUILT_SOURCES = OTconfigureArgs.hxx 40 41 OTconfigure_args-stamp : OTconfigure_args.hxx 42 OTconfigureArgs.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 19 19 20 20 /* Support for regular expression library */ 21 #undef HAS_LIBXML2 22 23 /* Support for regular expression library */ 21 24 #undef HAS_REGEX 22 23 /* Support for Xerces-C XML library */24 #undef HAS_XERCESC25 25 26 26 /* Define to 1 if you have the `alarm' function. */ … … 56 56 /* Define if you have LAPACK library. */ 57 57 #undef HAVE_LAPACK 58 59 /* Define to 1 if you have the <libxml/parser.h> header file. */ 60 #undef HAVE_LIBXML_PARSER_H 58 61 59 62 /* Define to 1 if your system has a GNU libc compatible `malloc' function, and … … 124 127 #undef HAVE_UNISTD_H 125 128 126 /* Define to 1 if you have the <xercesc/dom/DOM.hpp> header file. */127 #undef HAVE_XERCESC_DOM_DOM_HPP128 129 /* Define to 1 if you have the <xercesc/framework/StdOutFormatTarget.hpp>130 header file. */131 #undef HAVE_XERCESC_FRAMEWORK_STDOUTFORMATTARGET_HPP132 133 /* Define to 1 if you have the <xercesc/parsers/XercesDOMParser.hpp> header134 file. */135 #undef HAVE_XERCESC_PARSERS_XERCESDOMPARSER_HPP136 137 /* Define to 1 if you have the <xercesc/util/PlatformUtils.hpp> header file.138 */139 #undef HAVE_XERCESC_UTIL_PLATFORMUTILS_HPP140 141 /* Define to 1 if you have the <xercesc/util/XercesVersion.hpp> header file.142 */143 #undef HAVE_XERCESC_UTIL_XERCESVERSION_HPP144 145 129 /* Define to 1 if the system has the type `_Bool'. */ 146 130 #undef HAVE__BOOL … … 189 173 #undef VERSION 190 174 191 /* Define to 1 if the X Window System is missing or not being used. */192 #undef X_DISPLAY_MISSING193 194 175 /* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a 195 176 `char[]'. */ trunk/lib/include/OTdebug.h
r941 r990 31 31 + __GNUC_MINOR__ * 100 \ 32 32 + __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 33 39 34 40 #define DEPRECATED __attribute__ ((deprecated)) trunk/lib/m4/examples/Makefile.am
r966 r990 25 25 bin_PROGRAMS = 26 26 AM_CPPFLAGS = $(OPENTURNS_CPPFLAGS) $(BOOST_CPPFLAGS) 27 AM_CXXFLAGS = $(QT_CXXFLAGS)28 27 AM_LDFLAGS = $(OPENTURNS_LDFLAGS) 29 28 LDADD = $(OPENTURNS_LIBS) trunk/lib/src/Base/Common/Catalog.cxx
r862 r990 98 98 if (catalog_.find(factoryName) == catalog_.end()) { 99 99 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"); 101 101 } 102 102 } trunk/lib/src/Base/Common/Exception.cxx
r941 r990 46 46 : names_() 47 47 { 48 //Log::Debug("ExceptionNames ctor");48 Log::Debug("ExceptionNames ctor"); 49 49 50 50 // Registration of destructor at exit 51 /* int rc = */ 52 std::atexit(ExceptionNames::release); 51 int rc = std::atexit(ExceptionNames::release); 53 52 54 //Log::Debug(OSS() << "ExceptionNames registration of destructor = " << (rc ? "ERROR" : "OK") );53 Log::Debug(OSS() << "ExceptionNames registration of destructor = " << (rc ? "ERROR" : "OK") ); 55 54 56 55 std::vector<String> & ref_names_ = *static_cast<std::vector<String> *>(&names_); trunk/lib/src/Base/Common/Log.cxx
r941 r990 166 166 167 167 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 */ 169 169 void Log::Show(Severity flags) 170 170 { … … 172 172 } 173 173 174 175 174 Log::Severity Log::Flags() 175 { 176 return Log::Severity_; 177 } 178 179 176 180 /* Append an entry at the end of the list */ 177 181 void Log::push(const Entry & entry) trunk/lib/src/Base/Common/Log.hxx
r941 r990 74 74 static void SetFile(const FileName & file); 75 75 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 */ 77 77 static void Show(Severity flags); 78 static Severity Flags(); 78 79 79 80 trunk/lib/src/Base/Common/Makefile.am
r974 r990 47 47 Thread.hxx \ 48 48 StorageManager.hxx \ 49 XMLStorageManager.hxx \50 49 WrapperInterface.h \ 51 50 Path.hxx \ … … 68 67 69 68 noinst_LTLIBRARIES = libOTCommon.la 70 libOTCommon_la_CXXFLAGS = $(AM_CXXFLAGS) $(QT_CXXFLAGS)69 libOTCommon_la_CXXFLAGS = $(AM_CXXFLAGS) 71 70 libOTCommon_la_LDFLAGS = -no-undefined 72 libOTCommon_la_LIBADD = $(QT_LIBS)71 libOTCommon_la_LIBADD = 73 72 libOTCommon_la_SOURCES = \ 74 73 OSS.cxx \ … … 87 86 Thread.cxx \ 88 87 StorageManager.cxx \ 89 XMLStorageManager.cxx \90 88 Path.cxx \ 91 89 ComparisonOperator.cxx \ … … 104 102 105 103 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 104 if WITH_LIBXML2 105 AM_CPPFLAGS += -I$(libxml2_include_path) 106 libOTCommon_la_LDFLAGS += -L$(libxml2_lib_path) 107 libOTCommon_la_LIBADD += -l$(libxml2_lib_name) 108 otinclude_HEADERS += \ 109 XMLStorageManager.hxx \ 110 XMLToolbox.hxx 111 libOTCommon_la_SOURCES += \ 112 XMLStorageManager.cxx \ 113 XMLToolbox.cxx 114 endif trunk/lib/src/Base/Common/PersistentObject.hxx
r818 r990 152 152 { 153 153 if (! mgr.isSavedObject(id_)) { 154 StorageManager::Advocate adv = mgr.registerObject(*this, fromStudy);154 StorageManager::Advocate adv ( mgr.registerObject(*this, fromStudy) ); 155 155 save(adv); 156 156 mgr.markObjectAsSaved(id_); trunk/lib/src/Base/Common/PersistentObjectFactory.hxx
r862 r990 103 103 virtual PersistentObject * build(const StorageManager & mgr) const 104 104 { 105 StorageManager::Advocate adv = mgr.readObject();105 StorageManager::Advocate adv ( mgr.readObject() ); 106 106 107 107 PERSISTENT * p_rebuildObject = new PERSISTENT(); trunk/lib/src/Base/Common/PlatformInfo.cxx
r508 r990 25 25 */ 26 26 #include "OTconfig.hxx" 27 #include "OTconfigure _args.hxx"27 #include "OTconfigureArgs.hxx" 28 28 #include "OSS.hxx" 29 29 #include "PlatformInfo.hxx" trunk/lib/src/Base/Common/ResourceMap.cxx
r966 r990 24 24 * Id: $Id$ 25 25 */ 26 #include <qfile.h> // for QFile qtextstream.h27 #include <qtextstream.h> // for QTextStream28 26 #include <unistd.h> // for sysconf 29 27 #include "OSS.hxx" … … 32 30 #include "Path.hxx" 33 31 #include "Log.hxx" 32 #include "XMLToolbox.hxx" 34 33 35 34 #ifndef R_EXECUTABLE_PATH … … 37 36 #endif 38 37 38 #ifndef XML_SUPPORTED 39 #error "XML support is mandatory. Check configuration." 40 #endif 41 39 42 namespace OpenTURNS 40 43 { … … 45 48 namespace Common 46 49 { 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"; 49 55 50 56 Pointer<ResourceMap> ResourceMap::P_instance_; … … 103 109 } 104 110 111 #if defined HAS_LIBXML2 112 105 113 /* Update the ResourceMap with information from the configuration file */ 106 114 void ResourceMap::readConfigurationFile(const FileName & configurationFile) … … 109 117 110 118 // 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); 122 128 123 129 124 130 // 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 } 132 139 } 133 node = node.nextSibling();134 140 } 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 154 152 155 153 /* Find the configuration file in specific path (see Path class for algorithm) */ trunk/lib/src/Base/Common/ResourceMap.hxx
r815 r990 28 28 29 29 #include <map> 30 #include <qdom.h>31 30 #include "Pointer.hxx" 32 31 … … 94 93 void readConfigurationFile(const FileName & configurationFile); 95 94 96 /** Parse the configuration file */97 QDomDocument parseConfigurationFile(const FileName & configurationFile) const;98 99 95 /** Find the configuration file in specific path (see Path class for algorithm) */ 100 96 FileName findConfigurationFile() const; trunk/lib/src/Base/Common/StorageManager.cxx
r818 r990 42 42 43 43 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) 46 46 { 47 47 // Nothing to do … … 253 253 } 254 254 255 void StorageManager::Advocate::readValue(InterfaceObject & obj) const256 {257 p_implementation_->readValue(obj);258 }259 260 255 void StorageManager::Advocate::readValue(InterfaceObject & obj, AttributeName attribute, const String & st) const 261 256 { … … 263 258 } 264 259 265 void StorageManager::Advocate::readValue(PersistentObject & obj) const266 {267 p_implementation_->readValue(obj);268 }269 270 260 void StorageManager::Advocate::readValue(PersistentObject & obj, AttributeName attribute, const String & st) const 271 261 { 272 262 p_implementation_->readValue(obj, attribute, st); 273 }274 275 void StorageManager::Advocate::firstValueToRead() const276 {277 p_implementation_->firstValueToRead();278 }279 280 Bool StorageManager::Advocate::moreValuesToRead() const281 {282 return p_implementation_->moreValuesToRead();283 }284 285 void StorageManager::Advocate::nextValueToRead() const286 {287 p_implementation_->nextValueToRead();288 263 } 289 264 … … 519 494 } 520 495 521 void StorageManager::AdvocateImplementation::readValue(InterfaceObject & obj) const522 {523 p_manager_->readValue(obj);524 }525 526 496 void StorageManager::AdvocateImplementation::readValue(InterfaceObject & obj, AttributeName attribute, const String & st) const 527 497 { … … 529 499 } 530 500 531 void StorageManager::AdvocateImplementation::readValue(PersistentObject & obj) const532 {533 p_manager_->readValue(obj);534 }535 536 501 void StorageManager::AdvocateImplementation::readValue(PersistentObject & obj, AttributeName attribute, const String & st) const 537 502 { 538 503 p_manager_->readValue(obj, attribute, st); 539 504 } 540 541 void StorageManager::AdvocateImplementation::firstValueToRead() const542 {543 p_manager_->firstValueToRead();544 }545 546 Bool StorageManager::AdvocateImplementation::moreValuesToRead() const547 {548 return p_manager_->moreValuesToRead();549 }550 551 void StorageManager::AdvocateImplementation::nextValueToRead() const552 {553 p_manager_->nextValueToRead();554 }555 556 505 557 506 … … 761 710 * This method build a new advocate to talk to the storage manager 762 711 */ 763 StorageManager::WriteAdvocateImplementationStorageManager::registerObject(const PersistentObject & obj, bool fromStudy) const764 { 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); 766 715 } 767 716 … … 771 720 * This method build a new advocate to talk to the storage manager 772 721 */ 773 StorageManager::ReadAdvocateImplementationStorageManager::readObject() const774 { 775 return ReadAdvocateImplementation(const_cast<StorageManager *>(this));722 Pointer<StorageManager::ReadAdvocateImplementation> StorageManager::readObject() const 723 { 724 return new ReadAdvocateImplementation(const_cast<StorageManager *>(this)); 776 725 } 777 726 … … 988 937 } 989 938 990 void StorageManager::readValue(InterfaceObject & obj)991 {992 throw NotDefinedException(HERE);993 }994 995 939 void StorageManager::readValue(InterfaceObject & obj, AttributeName attribute, const String & st) 996 940 { … … 998 942 } 999 943 1000 void StorageManager::readValue(PersistentObject & obj)1001 {1002 throw NotDefinedException(HERE);1003 }1004 1005 944 void StorageManager::readValue(PersistentObject & obj, AttributeName attribute, const String & st) 1006 945 { 1007 946 throw NotDefinedException(HERE); 1008 947 } 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 1026 948 1027 949 trunk/lib/src/Base/Common/StorageManager.hxx
r877 r990 201 201 void readAttribute(AttributeName attribute, UnsignedLong & ul) const; 202 202 203 void firstValueToRead() const;204 Bool moreValuesToRead() const;205 void nextValueToRead() const;206 203 // template <class T> void readValue(UnsignedLong & index, T & value) const 207 204 // { return p_manager_->readValue(index,value); } … … 220 217 void readValue(String & name, UnsignedLong & value) const; 221 218 void readValue(String & name, Bool & value) const; 222 void readValue(InterfaceObject & obj) const;223 219 void readValue(InterfaceObject & obj, AttributeName attribute, const String & st) const; 224 void readValue(PersistentObject & obj) const;225 220 void readValue(PersistentObject & obj, AttributeName attribute, const String & st) const; 226 221 … … 266 261 * This method build a new advocate to talk to the storage manager 267 262 */ 268 WriteAdvocateImplementationregisterObject(const PersistentObject & obj, bool fromStudy = false) const;263 Pointer<WriteAdvocateImplementation> registerObject(const PersistentObject & obj, bool fromStudy = false) const; 269 264 270 265 /** 271 266 * This method build a new advocate to talk to the storage manager 272 267 */ 273 ReadAdvocateImplementationreadObject() const;268 Pointer<ReadAdvocateImplementation> readObject() const; 274 269 275 270 … … 279 274 { 280 275 public: 281 Advocate(const AdvocateImplementation & implementation); 276 typedef Pointer<AdvocateImplementation> Implementation; 277 278 Advocate(const Implementation & p_implementation); 282 279 virtual ~Advocate(); 283 280 … … 316 313 void readAttribute(AttributeName attribute, UnsignedLong & ul) const; 317 314 318 void firstValueToRead() const;319 Bool moreValuesToRead() const;320 void nextValueToRead() const;321 315 // template <class T> void readValue(UnsignedLong & index, T & value) const 322 316 // { return p_implementation_->readValue(index,value); } … … 335 329 void readValue(String & name, UnsignedLong & value) const; 336 330 void readValue(String & name, Bool & value) const; 337 void readValue(InterfaceObject & obj) const;338 331 void readValue(InterfaceObject & obj, AttributeName attribute, const String & st) const; 339 void readValue(PersistentObject & obj) const;340 332 void readValue(PersistentObject & obj, AttributeName attribute, const String & st) const; 341 333 342 334 private: 343 Pointer<AdvocateImplementation>p_implementation_;335 Implementation p_implementation_; 344 336 345 337 }; /* end class Advocate */ … … 461 453 virtual void readAttribute(AttributeName attribute, UnsignedLong & ul); 462 454 463 virtual void firstValueToRead();464 virtual Bool moreValuesToRead();465 virtual void nextValueToRead();466 455 // template <class T> void readValue(UnsignedLong & index, T & value) const 467 456 // { throw NotDefinedException(HERE); } … … 480 469 virtual void readValue(String & name, UnsignedLong & value); 481 470 virtual void readValue(String & name, Bool & value); 482 virtual void readValue(InterfaceObject & obj);483 471 virtual void readValue(InterfaceObject & obj, AttributeName attribute, const String & st); 484 virtual void readValue(PersistentObject & obj);485 472 virtual void readValue(PersistentObject & obj, AttributeName attribute, const String & st); 486 473 trunk/lib/src/Base/Common/XMLStorageManager.cxx
r862 r990 24 24 * Id: $Id$ 25 25 */ 26 #include <qfile.h> // for QFile qtextstream.h27 #include <qtextstream.h> // for QTextSream28 26 #include "XMLStorageManager.hxx" 29 //#include "StringXMLConverter.hxx"30 27 #include "PersistentObject.hxx" 31 28 #include "InterfaceObject.hxx" … … 34 31 #include "Study.hxx" 35 32 #include "OSS.hxx" 36 33 #include "Log.hxx" 37 34 38 35 … … 46 43 { 47 44 48 const StringRootElementName = "openturns-study";45 static const char * RootElementName = "openturns-study"; 49 46 50 47 XMLStorageManager::XMLList::XMLList(const XMLStorageManager & mgr, State state, EntityName entity) 51 : nodeList_( state.current_.elementsByTagName(mgr.getEntityString(entity))),48 : nodeList_(XML::GetFirstChild(state.current_)), 52 49 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_; 56 57 } 57 58 … … 63 64 UnsignedLong XMLStorageManager::XMLList::getSize() const 64 65 { 65 return nodeList_.length();66 return length_; 66 67 } 67 68 68 69 void XMLStorageManager::XMLList::firstValueToRead() 69 70 { 70 cursor_ = 0; 71 for( cursor_ = nodeList_; cursor_; cursor_ = XML::GetNextNode(cursor_) ) 72 if (XML::IsElement(cursor_, manager_.getEntityString(entity_))) break; 71 73 } 72 74 73 75 Bool XMLStorageManager::XMLList::moreValuesToRead() 74 76 { 75 return (cursor_ < nodeList_.length());77 return (cursor_ != NULL); 76 78 } 77 79 78 80 void XMLStorageManager::XMLList::nextValueToRead() 79 81 { 80 ++cursor_; 82 while ( (cursor_ = XML::GetNextNode(cursor_)) != NULL ) 83 if (XML::IsElement(cursor_, manager_.getEntityString(entity_))) break; 81 84 } 82 85 83 86 Bool XMLStorageManager::XMLList::readValue(UnsignedLong & index, NumericalScalar & value) 84 87 { 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)); 91 93 std::istringstream iss (stidx); 92 94 iss >> index; 93 95 } 94 96 { 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; 103 101 } 104 102 } … … 108 106 Bool XMLStorageManager::XMLList::readValue(UnsignedLong & index, NumericalComplex & value) 109 107 { 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)); 116 113 std::istringstream iss (stidx); 117 114 iss >> index; 118 115 } 119 116 { 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; 128 121 } 129 122 } … … 133 126 Bool XMLStorageManager::XMLList::readValue(UnsignedLong & index, InterfaceObject & obj) 134 127 { 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)); 141 133 std::istringstream iss (stidx); 142 134 iss >> index; … … 144 136 { 145 137 Id shadowedId; 146 String stid = element.attribute(manager_.getAttributeString(IdAttribute), "");138 String stid = XML::GetAttributeByName(cursor_, manager_.getAttributeString(IdAttribute)); 147 139 std::istringstream iss (stid); 148 140 iss >> shadowedId; … … 157 149 Bool XMLStorageManager::XMLList::readValue(UnsignedLong & index, PersistentObject & obj) 158 150 { 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)); 165 156 std::istringstream iss (stidx); 166 157 iss >> index; … … 168 159
