#include "sopnamsp.h" #include "machdefs.h" #include #include #include #include #include "sophyainit.h" #include "pexceptions.h" #include "ppersist.h" #include "fiondblock.h" #include "dvlist.h" #include "fiosegdb.h" #include "ppfwrapstlv.h" #include "sversion.h" #include #include // --- Classe d'initialisation de SOPHYA, (PPersistMgr en particulier) int SophyaInitiator::FgInit = 0; // Module version number - 2.0 , Jul 2006 // Module version number - 2.02 , Fev07 Ajout NDataBlock::RenewObjId() #define MOD_VERS 2.02 // Pour garder la liste des modules et leurs numeros de version map* ModListP = NULL; /*! \namespace SOPHYA \brief This is the namespace for the whole Sophya package */ /*! \class SOPHYA::SophyaInitiator \ingroup BaseTools Each Sophya module may contain an initialiser class which should be a sub-class of SophyaInitiator. */ SophyaInitiator::SophyaInitiator() { #if defined(Darwin) // Il semble y avoir un probleme sous MacOSX ... if (FgInit == 0) cout << " SophyaInitiator::SophyaInitiator() BaseTools Init" << endl; #endif FgInit++; if (FgInit > 1) return; InitFailNewHandler(); ModListP = new map; #ifdef xx__mac__ //InitToolBox(); //SIOUXSettings.initializeTB = FALSE; SIOUXSettings.autocloseonquit = FALSE; SIOUXSettings.asktosaveonclose = FALSE; SIOUXSettings.showstatusline = TRUE; #endif // Initialisation des mecanismes PPF I/O PIOPersist::Initialize(); // Enregistrement des handlers PPF pour les NDataBlock PPRegister(FIO_NDataBlock); DObjRegister(FIO_NDataBlock, NDataBlock); PPRegister(FIO_NDataBlock); DObjRegister(FIO_NDataBlock, NDataBlock); PPRegister(FIO_NDataBlock); DObjRegister(FIO_NDataBlock, NDataBlock); PPRegister(FIO_NDataBlock); DObjRegister(FIO_NDataBlock, NDataBlock); PPRegister(FIO_NDataBlock); DObjRegister(FIO_NDataBlock, NDataBlock); PPRegister(FIO_NDataBlock); DObjRegister(FIO_NDataBlock, NDataBlock); PPRegister(FIO_NDataBlock); DObjRegister(FIO_NDataBlock, NDataBlock); PPRegister(FIO_NDataBlock); DObjRegister(FIO_NDataBlock, NDataBlock); PPRegister(FIO_NDataBlock); DObjRegister(FIO_NDataBlock, NDataBlock); PPRegister(FIO_NDataBlock< complex >); DObjRegister(FIO_NDataBlock< complex >, NDataBlock< complex >); PPRegister(FIO_NDataBlock< complex >); DObjRegister(FIO_NDataBlock< complex >, NDataBlock< complex >); // Enregistrement des handlers PPF pour les TimeStamp PPRegister(ObjFileIO); DObjRegister(ObjFileIO, TimeStamp); // Enregistrement des handlers PPF pour les DVList PPRegister(ObjFileIO); DObjRegister(ObjFileIO, DVList); // Enregistrement des handlers PPF pour les SegDataBlock PPRegister(FIO_SegDataBlock); DObjRegister(FIO_SegDataBlock, SegDataBlock); PPRegister(FIO_SegDataBlock); DObjRegister(FIO_SegDataBlock, SegDataBlock); PPRegister(FIO_SegDataBlock); DObjRegister(FIO_SegDataBlock, SegDataBlock); PPRegister(FIO_SegDataBlock); DObjRegister(FIO_SegDataBlock, SegDataBlock); PPRegister(FIO_SegDataBlock); DObjRegister(FIO_SegDataBlock, SegDataBlock); PPRegister(FIO_SegDataBlock); DObjRegister(FIO_SegDataBlock, SegDataBlock); PPRegister(FIO_SegDataBlock); DObjRegister(FIO_SegDataBlock, SegDataBlock); PPRegister(FIO_SegDataBlock); DObjRegister(FIO_SegDataBlock, SegDataBlock); PPRegister(FIO_SegDataBlock< complex >); DObjRegister(FIO_SegDataBlock< complex >, SegDataBlock< complex >); PPRegister(FIO_SegDataBlock< complex >); DObjRegister(FIO_SegDataBlock< complex >, SegDataBlock< complex >); PPRegister(FIO_SegDataBlock); DObjRegister(FIO_SegDataBlock, SegDataBlock); // Enregistrement des handlers PPF pour les vecteurs de la STL PPRegister(PPFWrapperSTLVector); DObjRegister(PPFWrapperSTLVector, std::vector); PPRegister(PPFWrapperSTLVector); DObjRegister(PPFWrapperSTLVector, std::vector); PPRegister(PPFWrapperSTLVector); DObjRegister(PPFWrapperSTLVector, std::vector); PPRegister(PPFWrapperSTLVector); DObjRegister(PPFWrapperSTLVector, std::vector); PPRegister(PPFWrapperSTLVector); DObjRegister(PPFWrapperSTLVector, std::vector); PPRegister(PPFWrapperSTLVector); DObjRegister(PPFWrapperSTLVector, std::vector); PPRegister(PPFWrapperSTLVector); DObjRegister(PPFWrapperSTLVector, std::vector); PPRegister(PPFWrapperSTLVector); DObjRegister(PPFWrapperSTLVector, std::vector); PPRegister(PPFWrapperSTLVector< complex >); DObjRegister(PPFWrapperSTLVector< complex >, std::vector< complex >); PPRegister(PPFWrapperSTLVector< complex >); DObjRegister(PPFWrapperSTLVector< complex >, std::vector< complex >); PPRegister(PPFWrapperSTLVector< string >); DObjRegister(PPFWrapperSTLVector< string >, std::vector); PPRegister(PPFWrapperSTLVector< TimeStamp >); DObjRegister(PPFWrapperSTLVector< TimeStamp >, std::vector); #if (!defined(__GNUG__) && !defined(HPUX)) // pas de bufferisation pour printf cmv 18/3/97 selon E.A. // setvbuf(stdout,NULL,_IOLBF,0); setvbuf(stderr,NULL,_IOLBF,0); setlinebuf(stdout); setlinebuf(stderr); #endif // si var env SOPHYA_NOPRTVER definie pas de print if(!getenv("SOPHYA_NOPRTVER")) PrintVersion(false); int pnice; char* snice = getenv("SOPHYA_NICE"); if (!snice) pnice=8; else pnice = atoi(snice); nice(pnice); SophyaInitiator::RegisterModule("BaseTools", MOD_VERS); // Module name and version number registration } SophyaInitiator::~SophyaInitiator() { FgInit--; /* if (FgInit == 0) { delete PPersistMgr::classList; PPersistMgr::classList = NULL; delete PShPersist::objList; PShPersist::objList = NULL; } */ } /*! \brief Return the SOPHYA version number. \param svers contain the complete in addition the SOPHYA tag, the compiler name and the compilation date */ double SophyaInitiator::GetVersion(string& svers) { char* compiler = 0; #ifdef __GNUG__ compiler = "gcc " __VERSION__; #endif #ifdef __DECCXX compiler = "cxx " ; #endif #ifdef __aCC__ compiler = const_cast("HP-aCC ") ; #endif #ifdef __KCC__ compiler = const_cast("KCC ") ; #endif #ifdef __IBMCPP__ #ifdef SO_ARCH64 compiler = const_cast("IBM-xlC ") ; #else compiler = const_cast("IBM-xlC (-q64)") ; #endif #endif #ifdef __INTEL_COMPILER compiler = const_cast("Intel-icc ") ; #endif #ifdef __SGICC__ #ifdef SO_ARCH64 compiler = const_cast("SGI-CC (-64) ") ; #else compiler = const_cast("SGI-CC ") ; #endif #endif char buff[512]; sprintf(buff,"SOPHYA Version %4.1f Revision %d (%s) -- %s %s %s", SOPHYA_VERSION, SOPHYA_REVISION, SOPHYA_TAG, __DATE__, __TIME__, compiler); svers = buff; return(SOPHYA_VERSION + (SOPHYA_REVISION/1000.)); } //! Print the SOPHYA version string and optionaly the list of registered modules void SophyaInitiator::PrintVersion(bool fglist) { string svers; GetVersion(svers); cout << svers << endl; if (fglist) ListModules(cout); } //! Should be called by sub-classes to register module name and version int SophyaInitiator::RegisterModule(const char * name, double version) { if (ModListP == NULL) throw NullPtrError("SophyaInitiator::RegisterModule() ModListP= NULL !"); map& modlist = *ModListP; modlist[string(name)] = version; return modlist.size(); } //! List of registered module names and version number int SophyaInitiator::ListModules(ostream& os) { if (ModListP == NULL) throw NullPtrError("SophyaInitiator::ListModules() ModListP= NULL !"); os << "--- SophyaInitiator::ListModules() Name / VersionNumber --- " << endl; map& modlist = *ModListP; int k = 1; for(map::iterator it = modlist.begin(); it != modlist.end(); it++, k++) os << k << " : " << (*it).first << " V= " << (*it).second << endl; os << " ----------------------------------------------------------- " << endl; return modlist.size(); } //! Return the SOPHYA version number: VERS + REV/1000 double SOPHYA::SophyaVersion() { return(SOPHYA_VERSION + (SOPHYA_REVISION/1000.)); } // On met un objet initiator en statique, pour les loaders qui savent // appeler le constructeur des objets statiques Reza 08/98 // La presence de l'objet statique psophyainit semble poserun probleme // sur MacOSX 10.2 qui se plante a l'initialisation avec les shared-libs // Suppression de #if !defined(Darwin) en Juil 2006 static SophyaInitiator psophyainit;