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