[2615] | 1 | #include "sopnamsp.h"
|
---|
[754] | 2 | #include "machdefs.h"
|
---|
| 3 |
|
---|
| 4 | #include <unistd.h>
|
---|
| 5 | #include <stdlib.h>
|
---|
| 6 | #include <stdio.h>
|
---|
| 7 | #include <complex>
|
---|
| 8 |
|
---|
| 9 | #include "sophyainit.h"
|
---|
| 10 |
|
---|
| 11 | #include "pexceptions.h"
|
---|
| 12 |
|
---|
| 13 | #include "ppersist.h"
|
---|
[802] | 14 | #include "fiondblock.h"
|
---|
[754] | 15 | #include "dvlist.h"
|
---|
| 16 |
|
---|
[2660] | 17 | #include "fiosegdb.h"
|
---|
| 18 | #include "ppfwrapstlv.h"
|
---|
| 19 |
|
---|
[754] | 20 | #include "sversion.h"
|
---|
| 21 |
|
---|
[3016] | 22 | #include <iostream>
|
---|
| 23 | #include <map>
|
---|
| 24 |
|
---|
[754] | 25 | // --- Classe d'initialisation de SOPHYA, (PPersistMgr en particulier)
|
---|
| 26 | int SophyaInitiator::FgInit = 0;
|
---|
[3016] | 27 | // Module version number - 2.0 , Jul 2006
|
---|
[3172] | 28 | // Module version number - 2.02 , Fev07 Ajout NDataBlock::RenewObjId()
|
---|
[3213] | 29 | // Module version number - 2.1 , Avr07
|
---|
| 30 | // - Nettoyage machdefs_mkmf.h
|
---|
| 31 | // - Ajout classe ThSafeOp ---> NDataBlock<T> Sw/SegDataBlock<T> ThreadSafe
|
---|
| 32 | //
|
---|
[3228] | 33 | #define MOD_VERS 2.1
|
---|
[754] | 34 |
|
---|
[3016] | 35 | // Pour garder la liste des modules et leurs numeros de version
|
---|
| 36 | map<string, double>* ModListP = NULL;
|
---|
| 37 |
|
---|
[913] | 38 | /*!
|
---|
| 39 | \namespace SOPHYA
|
---|
| 40 | \brief This is the namespace for the whole Sophya package
|
---|
| 41 | */
|
---|
| 42 |
|
---|
| 43 | /*!
|
---|
| 44 | \class SOPHYA::SophyaInitiator
|
---|
[1607] | 45 | \ingroup BaseTools
|
---|
[913] | 46 | Each Sophya module may contain an initialiser class which should
|
---|
| 47 | be a sub-class of SophyaInitiator.
|
---|
| 48 | */
|
---|
| 49 |
|
---|
[3016] | 50 |
|
---|
[754] | 51 | SophyaInitiator::SophyaInitiator()
|
---|
| 52 | {
|
---|
[1900] | 53 | #if defined(Darwin)
|
---|
| 54 | // Il semble y avoir un probleme sous MacOSX ...
|
---|
| 55 | if (FgInit == 0)
|
---|
| 56 | cout << " SophyaInitiator::SophyaInitiator() BaseTools Init" << endl;
|
---|
| 57 | #endif
|
---|
[754] | 58 | FgInit++;
|
---|
| 59 | if (FgInit > 1) return;
|
---|
| 60 |
|
---|
| 61 | InitFailNewHandler();
|
---|
[3016] | 62 | ModListP = new map<string, double>;
|
---|
| 63 |
|
---|
[754] | 64 |
|
---|
[2660] | 65 | // Initialisation des mecanismes PPF I/O
|
---|
[754] | 66 | PIOPersist::Initialize();
|
---|
[2660] | 67 | // Enregistrement des handlers PPF pour les NDataBlock<T>
|
---|
[754] | 68 | PPRegister(FIO_NDataBlock<uint_1>);
|
---|
[802] | 69 | DObjRegister(FIO_NDataBlock<uint_1>, NDataBlock<uint_1>);
|
---|
[754] | 70 | PPRegister(FIO_NDataBlock<uint_2>);
|
---|
[802] | 71 | DObjRegister(FIO_NDataBlock<uint_2>, NDataBlock<uint_2>);
|
---|
[754] | 72 | PPRegister(FIO_NDataBlock<int_2>);
|
---|
[802] | 73 | DObjRegister(FIO_NDataBlock<int_2>, NDataBlock<int_2>);
|
---|
[754] | 74 | PPRegister(FIO_NDataBlock<int_4>);
|
---|
[802] | 75 | DObjRegister(FIO_NDataBlock<int_4>, NDataBlock<int_4>);
|
---|
[754] | 76 | PPRegister(FIO_NDataBlock<int_8>);
|
---|
[802] | 77 | DObjRegister(FIO_NDataBlock<int_8>, NDataBlock<int_8>);
|
---|
[754] | 78 | PPRegister(FIO_NDataBlock<uint_4>);
|
---|
[802] | 79 | DObjRegister(FIO_NDataBlock<uint_4>, NDataBlock<uint_4>);
|
---|
[754] | 80 | PPRegister(FIO_NDataBlock<uint_8>);
|
---|
[802] | 81 | DObjRegister(FIO_NDataBlock<uint_8>, NDataBlock<uint_8>);
|
---|
[754] | 82 | PPRegister(FIO_NDataBlock<r_4>);
|
---|
[802] | 83 | DObjRegister(FIO_NDataBlock<r_4>, NDataBlock<r_4>);
|
---|
[754] | 84 | PPRegister(FIO_NDataBlock<r_8>);
|
---|
[802] | 85 | DObjRegister(FIO_NDataBlock<r_8>, NDataBlock<r_8>);
|
---|
| 86 | PPRegister(FIO_NDataBlock< complex<r_4> >);
|
---|
| 87 | DObjRegister(FIO_NDataBlock< complex<r_4> >, NDataBlock< complex<r_4> >);
|
---|
| 88 | PPRegister(FIO_NDataBlock< complex<r_8> >);
|
---|
| 89 | DObjRegister(FIO_NDataBlock< complex<r_8> >, NDataBlock< complex<r_8> >);
|
---|
[754] | 90 |
|
---|
[2830] | 91 | // Enregistrement des handlers PPF pour les TimeStamp
|
---|
| 92 | PPRegister(ObjFileIO<TimeStamp>);
|
---|
| 93 | DObjRegister(ObjFileIO<TimeStamp>, TimeStamp);
|
---|
| 94 |
|
---|
[2660] | 95 | // Enregistrement des handlers PPF pour les DVList
|
---|
[754] | 96 | PPRegister(ObjFileIO<DVList>);
|
---|
[802] | 97 | DObjRegister(ObjFileIO<DVList>, DVList);
|
---|
[754] | 98 |
|
---|
[2660] | 99 | // Enregistrement des handlers PPF pour les SegDataBlock<T>
|
---|
| 100 | PPRegister(FIO_SegDataBlock<uint_2>);
|
---|
| 101 | DObjRegister(FIO_SegDataBlock<uint_2>, SegDataBlock<uint_2>);
|
---|
| 102 | PPRegister(FIO_SegDataBlock<int_2>);
|
---|
| 103 | DObjRegister(FIO_SegDataBlock<int_2>, SegDataBlock<int_2>);
|
---|
| 104 | PPRegister(FIO_SegDataBlock<int_4>);
|
---|
| 105 | DObjRegister(FIO_SegDataBlock<int_4>, SegDataBlock<int_4>);
|
---|
| 106 | PPRegister(FIO_SegDataBlock<int_8>);
|
---|
| 107 | DObjRegister(FIO_SegDataBlock<int_8>, SegDataBlock<int_8>);
|
---|
| 108 | PPRegister(FIO_SegDataBlock<uint_4>);
|
---|
| 109 | DObjRegister(FIO_SegDataBlock<uint_4>, SegDataBlock<uint_4>);
|
---|
| 110 | PPRegister(FIO_SegDataBlock<uint_8>);
|
---|
| 111 | DObjRegister(FIO_SegDataBlock<uint_8>, SegDataBlock<uint_8>);
|
---|
| 112 | PPRegister(FIO_SegDataBlock<r_4>);
|
---|
| 113 | DObjRegister(FIO_SegDataBlock<r_4>, SegDataBlock<r_4>);
|
---|
| 114 | PPRegister(FIO_SegDataBlock<r_8>);
|
---|
| 115 | DObjRegister(FIO_SegDataBlock<r_8>, SegDataBlock<r_8>);
|
---|
| 116 | PPRegister(FIO_SegDataBlock< complex<r_4> >);
|
---|
| 117 | DObjRegister(FIO_SegDataBlock< complex<r_4> >, SegDataBlock< complex<r_4> >);
|
---|
| 118 | PPRegister(FIO_SegDataBlock< complex<r_8> >);
|
---|
| 119 | DObjRegister(FIO_SegDataBlock< complex<r_8> >, SegDataBlock< complex<r_8> >);
|
---|
| 120 | PPRegister(FIO_SegDataBlock<string>);
|
---|
| 121 | DObjRegister(FIO_SegDataBlock<string>, SegDataBlock<string>);
|
---|
[754] | 122 |
|
---|
[2660] | 123 | // Enregistrement des handlers PPF pour les vecteurs de la STL
|
---|
| 124 | PPRegister(PPFWrapperSTLVector<uint_2>);
|
---|
| 125 | DObjRegister(PPFWrapperSTLVector<uint_2>, std::vector<uint_2>);
|
---|
| 126 | PPRegister(PPFWrapperSTLVector<int_2>);
|
---|
| 127 | DObjRegister(PPFWrapperSTLVector<int_2>, std::vector<int_2>);
|
---|
| 128 | PPRegister(PPFWrapperSTLVector<int_4>);
|
---|
| 129 | DObjRegister(PPFWrapperSTLVector<int_4>, std::vector<int_4>);
|
---|
| 130 | PPRegister(PPFWrapperSTLVector<int_8>);
|
---|
| 131 | DObjRegister(PPFWrapperSTLVector<int_8>, std::vector<int_8>);
|
---|
| 132 | PPRegister(PPFWrapperSTLVector<uint_4>);
|
---|
| 133 | DObjRegister(PPFWrapperSTLVector<uint_4>, std::vector<uint_4>);
|
---|
| 134 | PPRegister(PPFWrapperSTLVector<uint_8>);
|
---|
| 135 | DObjRegister(PPFWrapperSTLVector<uint_8>, std::vector<uint_8>);
|
---|
| 136 | PPRegister(PPFWrapperSTLVector<r_4>);
|
---|
| 137 | DObjRegister(PPFWrapperSTLVector<r_4>, std::vector<r_4>);
|
---|
| 138 | PPRegister(PPFWrapperSTLVector<r_8>);
|
---|
| 139 | DObjRegister(PPFWrapperSTLVector<r_8>, std::vector<r_8>);
|
---|
| 140 | PPRegister(PPFWrapperSTLVector< complex<r_4> >);
|
---|
| 141 | DObjRegister(PPFWrapperSTLVector< complex<r_4> >, std::vector< complex<r_4> >);
|
---|
| 142 | PPRegister(PPFWrapperSTLVector< complex<r_8> >);
|
---|
| 143 | DObjRegister(PPFWrapperSTLVector< complex<r_8> >, std::vector< complex<r_8> >);
|
---|
[2774] | 144 | PPRegister(PPFWrapperSTLVector< string >);
|
---|
| 145 | DObjRegister(PPFWrapperSTLVector< string >, std::vector<string>);
|
---|
[2660] | 146 |
|
---|
[2830] | 147 | PPRegister(PPFWrapperSTLVector< TimeStamp >);
|
---|
| 148 | DObjRegister(PPFWrapperSTLVector< TimeStamp >, std::vector<TimeStamp>);
|
---|
[2660] | 149 |
|
---|
[2830] | 150 |
|
---|
[3203] | 151 | #if (!defined(__GNUG__) && !defined(HPUX))
|
---|
[754] | 152 | // pas de bufferisation pour printf cmv 18/3/97 selon E.A.
|
---|
| 153 | // setvbuf(stdout,NULL,_IOLBF,0); setvbuf(stderr,NULL,_IOLBF,0);
|
---|
| 154 | setlinebuf(stdout);
|
---|
| 155 | setlinebuf(stderr);
|
---|
| 156 | #endif
|
---|
| 157 |
|
---|
| 158 | // si var env SOPHYA_NOPRTVER definie pas de print
|
---|
[3016] | 159 | if(!getenv("SOPHYA_NOPRTVER")) PrintVersion(false);
|
---|
[754] | 160 |
|
---|
| 161 | int pnice;
|
---|
| 162 | char* snice = getenv("SOPHYA_NICE");
|
---|
| 163 | if (!snice) pnice=8;
|
---|
| 164 | else pnice = atoi(snice);
|
---|
| 165 | nice(pnice);
|
---|
| 166 |
|
---|
[3016] | 167 | SophyaInitiator::RegisterModule("BaseTools", MOD_VERS); // Module name and version number registration
|
---|
[754] | 168 | }
|
---|
| 169 |
|
---|
| 170 | SophyaInitiator::~SophyaInitiator()
|
---|
| 171 | {
|
---|
| 172 | FgInit--;
|
---|
| 173 | /*
|
---|
| 174 | if (FgInit == 0)
|
---|
| 175 | {
|
---|
| 176 | delete PPersistMgr::classList; PPersistMgr::classList = NULL;
|
---|
| 177 | delete PShPersist::objList; PShPersist::objList = NULL;
|
---|
| 178 | }
|
---|
| 179 | */
|
---|
| 180 | }
|
---|
| 181 |
|
---|
[3016] | 182 | /*!
|
---|
| 183 | \brief Return the SOPHYA version number.
|
---|
| 184 | \param svers contain the complete in addition the SOPHYA tag, the compiler name
|
---|
| 185 | and the compilation date
|
---|
| 186 | */
|
---|
| 187 | double SophyaInitiator::GetVersion(string& svers)
|
---|
[754] | 188 | {
|
---|
| 189 | char* compiler = 0;
|
---|
| 190 | #ifdef __GNUG__
|
---|
| 191 | compiler = "gcc " __VERSION__;
|
---|
| 192 | #endif
|
---|
| 193 | #ifdef __DECCXX
|
---|
| 194 | compiler = "cxx " ;
|
---|
| 195 | #endif
|
---|
| 196 | #ifdef __aCC__
|
---|
| 197 | compiler = const_cast<char *>("HP-aCC ") ;
|
---|
| 198 | #endif
|
---|
| 199 | #ifdef __KCC__
|
---|
| 200 | compiler = const_cast<char *>("KCC ") ;
|
---|
| 201 | #endif
|
---|
[3016] | 202 | #ifdef __IBMCPP__
|
---|
[3203] | 203 | #ifdef SO_ARCH64
|
---|
[3213] | 204 | compiler = const_cast<char *>("IBM-xlC (-q64)") ;
|
---|
[3203] | 205 | #else
|
---|
[3213] | 206 | compiler = const_cast<char *>("IBM-xlC") ;
|
---|
[3016] | 207 | #endif
|
---|
[3203] | 208 | #endif
|
---|
[3016] | 209 | #ifdef __INTEL_COMPILER
|
---|
| 210 | compiler = const_cast<char *>("Intel-icc ") ;
|
---|
| 211 | #endif
|
---|
[754] | 212 | #ifdef __SGICC__
|
---|
[3203] | 213 | #ifdef SO_ARCH64
|
---|
[1249] | 214 | compiler = const_cast<char *>("SGI-CC (-64) ") ;
|
---|
| 215 | #else
|
---|
[754] | 216 | compiler = const_cast<char *>("SGI-CC ") ;
|
---|
| 217 | #endif
|
---|
[1249] | 218 | #endif
|
---|
[3016] | 219 |
|
---|
| 220 | char buff[512];
|
---|
| 221 | sprintf(buff,"SOPHYA Version %4.1f Revision %d (%s) -- %s %s %s",
|
---|
[754] | 222 | SOPHYA_VERSION, SOPHYA_REVISION, SOPHYA_TAG,
|
---|
| 223 | __DATE__, __TIME__, compiler);
|
---|
[3016] | 224 | svers = buff;
|
---|
| 225 |
|
---|
| 226 | return(SOPHYA_VERSION + (SOPHYA_REVISION/1000.));
|
---|
[754] | 227 | }
|
---|
[3016] | 228 |
|
---|
| 229 | //! Print the SOPHYA version string and optionaly the list of registered modules
|
---|
| 230 | void SophyaInitiator::PrintVersion(bool fglist)
|
---|
| 231 | {
|
---|
| 232 | string svers;
|
---|
| 233 | GetVersion(svers);
|
---|
| 234 | cout << svers << endl;
|
---|
| 235 | if (fglist) ListModules(cout);
|
---|
[754] | 236 | }
|
---|
[1157] | 237 |
|
---|
[3016] | 238 | //! Should be called by sub-classes to register module name and version
|
---|
| 239 | int SophyaInitiator::RegisterModule(const char * name, double version)
|
---|
| 240 | {
|
---|
| 241 | if (ModListP == NULL)
|
---|
| 242 | throw NullPtrError("SophyaInitiator::RegisterModule() ModListP= NULL !");
|
---|
| 243 | map<string, double>& modlist = *ModListP;
|
---|
| 244 | modlist[string(name)] = version;
|
---|
| 245 | return modlist.size();
|
---|
| 246 | }
|
---|
| 247 |
|
---|
| 248 | //! List of registered module names and version number
|
---|
| 249 | int SophyaInitiator::ListModules(ostream& os)
|
---|
| 250 | {
|
---|
| 251 | if (ModListP == NULL)
|
---|
| 252 | throw NullPtrError("SophyaInitiator::ListModules() ModListP= NULL !");
|
---|
| 253 | os << "--- SophyaInitiator::ListModules() Name / VersionNumber --- " << endl;
|
---|
| 254 | map<string, double>& modlist = *ModListP;
|
---|
| 255 | int k = 1;
|
---|
| 256 | for(map<string, double>::iterator it = modlist.begin(); it != modlist.end(); it++, k++)
|
---|
| 257 | os << k << " : " << (*it).first << " V= " << (*it).second << endl;
|
---|
| 258 | os << " ----------------------------------------------------------- " << endl;
|
---|
| 259 | return modlist.size();
|
---|
| 260 | }
|
---|
| 261 |
|
---|
| 262 | //! Return the SOPHYA version number: VERS + REV/1000
|
---|
[1157] | 263 | double SOPHYA::SophyaVersion()
|
---|
| 264 | {
|
---|
| 265 | return(SOPHYA_VERSION + (SOPHYA_REVISION/1000.));
|
---|
| 266 | }
|
---|
[754] | 267 |
|
---|
| 268 | // On met un objet initiator en statique, pour les loaders qui savent
|
---|
| 269 | // appeler le constructeur des objets statiques Reza 08/98
|
---|
[2430] | 270 | // La presence de l'objet statique psophyainit semble poserun probleme
|
---|
| 271 | // sur MacOSX 10.2 qui se plante a l'initialisation avec les shared-libs
|
---|
[3016] | 272 | // Suppression de #if !defined(Darwin) en Juil 2006
|
---|
[754] | 273 | static SophyaInitiator psophyainit;
|
---|
[3016] | 274 |
|
---|