[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 |
|
---|
| 22 | // --- Classe d'initialisation de SOPHYA, (PPersistMgr en particulier)
|
---|
| 23 | int SophyaInitiator::FgInit = 0;
|
---|
| 24 |
|
---|
[913] | 25 | /*!
|
---|
| 26 | \namespace SOPHYA
|
---|
| 27 | \brief This is the namespace for the whole Sophya package
|
---|
| 28 | */
|
---|
| 29 |
|
---|
| 30 | /*!
|
---|
| 31 | \class SOPHYA::SophyaInitiator
|
---|
[1607] | 32 | \ingroup BaseTools
|
---|
[913] | 33 | Each Sophya module may contain an initialiser class which should
|
---|
| 34 | be a sub-class of SophyaInitiator.
|
---|
| 35 | */
|
---|
| 36 |
|
---|
[754] | 37 | SophyaInitiator::SophyaInitiator()
|
---|
| 38 | {
|
---|
[1900] | 39 | #if defined(Darwin)
|
---|
| 40 | // Il semble y avoir un probleme sous MacOSX ...
|
---|
| 41 | if (FgInit == 0)
|
---|
| 42 | cout << " SophyaInitiator::SophyaInitiator() BaseTools Init" << endl;
|
---|
| 43 | #endif
|
---|
[754] | 44 | FgInit++;
|
---|
| 45 | if (FgInit > 1) return;
|
---|
| 46 |
|
---|
| 47 | InitFailNewHandler();
|
---|
| 48 |
|
---|
| 49 | #ifdef xx__mac__
|
---|
| 50 | //InitToolBox();
|
---|
| 51 | //SIOUXSettings.initializeTB = FALSE;
|
---|
| 52 | SIOUXSettings.autocloseonquit = FALSE;
|
---|
| 53 | SIOUXSettings.asktosaveonclose = FALSE;
|
---|
| 54 | SIOUXSettings.showstatusline = TRUE;
|
---|
| 55 | #endif
|
---|
| 56 |
|
---|
[2660] | 57 | // Initialisation des mecanismes PPF I/O
|
---|
[754] | 58 | PIOPersist::Initialize();
|
---|
[2660] | 59 | // Enregistrement des handlers PPF pour les NDataBlock<T>
|
---|
[754] | 60 | PPRegister(FIO_NDataBlock<uint_1>);
|
---|
[802] | 61 | DObjRegister(FIO_NDataBlock<uint_1>, NDataBlock<uint_1>);
|
---|
[754] | 62 | PPRegister(FIO_NDataBlock<uint_2>);
|
---|
[802] | 63 | DObjRegister(FIO_NDataBlock<uint_2>, NDataBlock<uint_2>);
|
---|
[754] | 64 | PPRegister(FIO_NDataBlock<int_2>);
|
---|
[802] | 65 | DObjRegister(FIO_NDataBlock<int_2>, NDataBlock<int_2>);
|
---|
[754] | 66 | PPRegister(FIO_NDataBlock<int_4>);
|
---|
[802] | 67 | DObjRegister(FIO_NDataBlock<int_4>, NDataBlock<int_4>);
|
---|
[754] | 68 | PPRegister(FIO_NDataBlock<int_8>);
|
---|
[802] | 69 | DObjRegister(FIO_NDataBlock<int_8>, NDataBlock<int_8>);
|
---|
[754] | 70 | PPRegister(FIO_NDataBlock<uint_4>);
|
---|
[802] | 71 | DObjRegister(FIO_NDataBlock<uint_4>, NDataBlock<uint_4>);
|
---|
[754] | 72 | PPRegister(FIO_NDataBlock<uint_8>);
|
---|
[802] | 73 | DObjRegister(FIO_NDataBlock<uint_8>, NDataBlock<uint_8>);
|
---|
[754] | 74 | PPRegister(FIO_NDataBlock<r_4>);
|
---|
[802] | 75 | DObjRegister(FIO_NDataBlock<r_4>, NDataBlock<r_4>);
|
---|
[754] | 76 | PPRegister(FIO_NDataBlock<r_8>);
|
---|
[802] | 77 | DObjRegister(FIO_NDataBlock<r_8>, NDataBlock<r_8>);
|
---|
| 78 | PPRegister(FIO_NDataBlock< complex<r_4> >);
|
---|
| 79 | DObjRegister(FIO_NDataBlock< complex<r_4> >, NDataBlock< complex<r_4> >);
|
---|
| 80 | PPRegister(FIO_NDataBlock< complex<r_8> >);
|
---|
| 81 | DObjRegister(FIO_NDataBlock< complex<r_8> >, NDataBlock< complex<r_8> >);
|
---|
[754] | 82 |
|
---|
[2830] | 83 | // Enregistrement des handlers PPF pour les TimeStamp
|
---|
| 84 | PPRegister(ObjFileIO<TimeStamp>);
|
---|
| 85 | DObjRegister(ObjFileIO<TimeStamp>, TimeStamp);
|
---|
| 86 |
|
---|
[2660] | 87 | // Enregistrement des handlers PPF pour les DVList
|
---|
[754] | 88 | PPRegister(ObjFileIO<DVList>);
|
---|
[802] | 89 | DObjRegister(ObjFileIO<DVList>, DVList);
|
---|
[754] | 90 |
|
---|
[2660] | 91 | // Enregistrement des handlers PPF pour les SegDataBlock<T>
|
---|
| 92 | PPRegister(FIO_SegDataBlock<uint_2>);
|
---|
| 93 | DObjRegister(FIO_SegDataBlock<uint_2>, SegDataBlock<uint_2>);
|
---|
| 94 | PPRegister(FIO_SegDataBlock<int_2>);
|
---|
| 95 | DObjRegister(FIO_SegDataBlock<int_2>, SegDataBlock<int_2>);
|
---|
| 96 | PPRegister(FIO_SegDataBlock<int_4>);
|
---|
| 97 | DObjRegister(FIO_SegDataBlock<int_4>, SegDataBlock<int_4>);
|
---|
| 98 | PPRegister(FIO_SegDataBlock<int_8>);
|
---|
| 99 | DObjRegister(FIO_SegDataBlock<int_8>, SegDataBlock<int_8>);
|
---|
| 100 | PPRegister(FIO_SegDataBlock<uint_4>);
|
---|
| 101 | DObjRegister(FIO_SegDataBlock<uint_4>, SegDataBlock<uint_4>);
|
---|
| 102 | PPRegister(FIO_SegDataBlock<uint_8>);
|
---|
| 103 | DObjRegister(FIO_SegDataBlock<uint_8>, SegDataBlock<uint_8>);
|
---|
| 104 | PPRegister(FIO_SegDataBlock<r_4>);
|
---|
| 105 | DObjRegister(FIO_SegDataBlock<r_4>, SegDataBlock<r_4>);
|
---|
| 106 | PPRegister(FIO_SegDataBlock<r_8>);
|
---|
| 107 | DObjRegister(FIO_SegDataBlock<r_8>, SegDataBlock<r_8>);
|
---|
| 108 | PPRegister(FIO_SegDataBlock< complex<r_4> >);
|
---|
| 109 | DObjRegister(FIO_SegDataBlock< complex<r_4> >, SegDataBlock< complex<r_4> >);
|
---|
| 110 | PPRegister(FIO_SegDataBlock< complex<r_8> >);
|
---|
| 111 | DObjRegister(FIO_SegDataBlock< complex<r_8> >, SegDataBlock< complex<r_8> >);
|
---|
| 112 | PPRegister(FIO_SegDataBlock<string>);
|
---|
| 113 | DObjRegister(FIO_SegDataBlock<string>, SegDataBlock<string>);
|
---|
[754] | 114 |
|
---|
[2660] | 115 | // Enregistrement des handlers PPF pour les vecteurs de la STL
|
---|
| 116 | PPRegister(PPFWrapperSTLVector<uint_2>);
|
---|
| 117 | DObjRegister(PPFWrapperSTLVector<uint_2>, std::vector<uint_2>);
|
---|
| 118 | PPRegister(PPFWrapperSTLVector<int_2>);
|
---|
| 119 | DObjRegister(PPFWrapperSTLVector<int_2>, std::vector<int_2>);
|
---|
| 120 | PPRegister(PPFWrapperSTLVector<int_4>);
|
---|
| 121 | DObjRegister(PPFWrapperSTLVector<int_4>, std::vector<int_4>);
|
---|
| 122 | PPRegister(PPFWrapperSTLVector<int_8>);
|
---|
| 123 | DObjRegister(PPFWrapperSTLVector<int_8>, std::vector<int_8>);
|
---|
| 124 | PPRegister(PPFWrapperSTLVector<uint_4>);
|
---|
| 125 | DObjRegister(PPFWrapperSTLVector<uint_4>, std::vector<uint_4>);
|
---|
| 126 | PPRegister(PPFWrapperSTLVector<uint_8>);
|
---|
| 127 | DObjRegister(PPFWrapperSTLVector<uint_8>, std::vector<uint_8>);
|
---|
| 128 | PPRegister(PPFWrapperSTLVector<r_4>);
|
---|
| 129 | DObjRegister(PPFWrapperSTLVector<r_4>, std::vector<r_4>);
|
---|
| 130 | PPRegister(PPFWrapperSTLVector<r_8>);
|
---|
| 131 | DObjRegister(PPFWrapperSTLVector<r_8>, std::vector<r_8>);
|
---|
| 132 | PPRegister(PPFWrapperSTLVector< complex<r_4> >);
|
---|
| 133 | DObjRegister(PPFWrapperSTLVector< complex<r_4> >, std::vector< complex<r_4> >);
|
---|
| 134 | PPRegister(PPFWrapperSTLVector< complex<r_8> >);
|
---|
| 135 | DObjRegister(PPFWrapperSTLVector< complex<r_8> >, std::vector< complex<r_8> >);
|
---|
[2774] | 136 | PPRegister(PPFWrapperSTLVector< string >);
|
---|
| 137 | DObjRegister(PPFWrapperSTLVector< string >, std::vector<string>);
|
---|
[2660] | 138 |
|
---|
[2830] | 139 | PPRegister(PPFWrapperSTLVector< TimeStamp >);
|
---|
| 140 | DObjRegister(PPFWrapperSTLVector< TimeStamp >, std::vector<TimeStamp>);
|
---|
[2660] | 141 |
|
---|
[2830] | 142 |
|
---|
[754] | 143 | #if (!defined(__GNUG__) && !defined(__MWERKS__) && !defined(HPUX))
|
---|
| 144 | // pas de bufferisation pour printf cmv 18/3/97 selon E.A.
|
---|
| 145 | // setvbuf(stdout,NULL,_IOLBF,0); setvbuf(stderr,NULL,_IOLBF,0);
|
---|
| 146 | setlinebuf(stdout);
|
---|
| 147 | setlinebuf(stderr);
|
---|
| 148 | #endif
|
---|
| 149 |
|
---|
| 150 | // si var env SOPHYA_NOPRTVER definie pas de print
|
---|
| 151 | if(!getenv("SOPHYA_NOPRTVER")) Version(true);
|
---|
| 152 |
|
---|
| 153 | int pnice;
|
---|
| 154 | char* snice = getenv("SOPHYA_NICE");
|
---|
| 155 | if (!snice) pnice=8;
|
---|
| 156 | else pnice = atoi(snice);
|
---|
| 157 | nice(pnice);
|
---|
| 158 |
|
---|
| 159 | }
|
---|
| 160 |
|
---|
| 161 | SophyaInitiator::~SophyaInitiator()
|
---|
| 162 | {
|
---|
| 163 | FgInit--;
|
---|
| 164 | /*
|
---|
| 165 | if (FgInit == 0)
|
---|
| 166 | {
|
---|
| 167 | delete PPersistMgr::classList; PPersistMgr::classList = NULL;
|
---|
| 168 | delete PShPersist::objList; PShPersist::objList = NULL;
|
---|
| 169 | }
|
---|
| 170 | */
|
---|
| 171 | }
|
---|
| 172 |
|
---|
| 173 | double SophyaInitiator::Version(bool fgprt)
|
---|
| 174 | {
|
---|
| 175 | if (fgprt) {
|
---|
| 176 | char* compiler = 0;
|
---|
| 177 | #ifdef __GNUG__
|
---|
| 178 | compiler = "gcc " __VERSION__;
|
---|
| 179 | #endif
|
---|
| 180 | #ifdef __DECCXX
|
---|
| 181 | compiler = "cxx " ;
|
---|
| 182 | #endif
|
---|
| 183 | #ifdef __aCC__
|
---|
| 184 | compiler = const_cast<char *>("HP-aCC ") ;
|
---|
| 185 | #endif
|
---|
| 186 | #ifdef __KCC__
|
---|
| 187 | compiler = const_cast<char *>("KCC ") ;
|
---|
| 188 | #endif
|
---|
| 189 | #ifdef __SGICC__
|
---|
[1249] | 190 | #ifdef SGI_ARCH64
|
---|
| 191 | compiler = const_cast<char *>("SGI-CC (-64) ") ;
|
---|
| 192 | #else
|
---|
[754] | 193 | compiler = const_cast<char *>("SGI-CC ") ;
|
---|
| 194 | #endif
|
---|
[1249] | 195 | #endif
|
---|
[754] | 196 | #ifdef __MWERKS__
|
---|
| 197 | compiler = const_cast<char *>("Codewarrior ");
|
---|
| 198 | #endif
|
---|
| 199 | fprintf(stderr,"SOPHYA Version %4.1f Revision %d (%s) -- %s %s %s\n",
|
---|
| 200 | SOPHYA_VERSION, SOPHYA_REVISION, SOPHYA_TAG,
|
---|
| 201 | __DATE__, __TIME__, compiler);
|
---|
| 202 | }
|
---|
| 203 | return(SOPHYA_VERSION + (SOPHYA_REVISION/1000.));
|
---|
| 204 | }
|
---|
[1157] | 205 |
|
---|
| 206 | double SOPHYA::SophyaVersion()
|
---|
| 207 | {
|
---|
| 208 | return(SOPHYA_VERSION + (SOPHYA_REVISION/1000.));
|
---|
| 209 | }
|
---|
[754] | 210 |
|
---|
| 211 | // On met un objet initiator en statique, pour les loaders qui savent
|
---|
| 212 | // appeler le constructeur des objets statiques Reza 08/98
|
---|
[2430] | 213 | #if !defined(Darwin)
|
---|
| 214 | // La presence de l'objet statique psophyainit semble poserun probleme
|
---|
| 215 | // sur MacOSX 10.2 qui se plante a l'initialisation avec les shared-libs
|
---|
[754] | 216 | static SophyaInitiator psophyainit;
|
---|
[2430] | 217 | #endif
|
---|