| [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 |  | 
|---|
| [2660] | 83 | // Enregistrement des handlers PPF pour les DVList | 
|---|
| [754] | 84 | PPRegister(ObjFileIO<DVList>); | 
|---|
| [802] | 85 | DObjRegister(ObjFileIO<DVList>, DVList); | 
|---|
| [754] | 86 |  | 
|---|
| [2660] | 87 | // Enregistrement des handlers PPF pour les SegDataBlock<T> | 
|---|
|  | 88 | PPRegister(FIO_SegDataBlock<uint_2>); | 
|---|
|  | 89 | DObjRegister(FIO_SegDataBlock<uint_2>, SegDataBlock<uint_2>); | 
|---|
|  | 90 | PPRegister(FIO_SegDataBlock<int_2>); | 
|---|
|  | 91 | DObjRegister(FIO_SegDataBlock<int_2>, SegDataBlock<int_2>); | 
|---|
|  | 92 | PPRegister(FIO_SegDataBlock<int_4>); | 
|---|
|  | 93 | DObjRegister(FIO_SegDataBlock<int_4>, SegDataBlock<int_4>); | 
|---|
|  | 94 | PPRegister(FIO_SegDataBlock<int_8>); | 
|---|
|  | 95 | DObjRegister(FIO_SegDataBlock<int_8>, SegDataBlock<int_8>); | 
|---|
|  | 96 | PPRegister(FIO_SegDataBlock<uint_4>); | 
|---|
|  | 97 | DObjRegister(FIO_SegDataBlock<uint_4>, SegDataBlock<uint_4>); | 
|---|
|  | 98 | PPRegister(FIO_SegDataBlock<uint_8>); | 
|---|
|  | 99 | DObjRegister(FIO_SegDataBlock<uint_8>, SegDataBlock<uint_8>); | 
|---|
|  | 100 | PPRegister(FIO_SegDataBlock<r_4>); | 
|---|
|  | 101 | DObjRegister(FIO_SegDataBlock<r_4>, SegDataBlock<r_4>); | 
|---|
|  | 102 | PPRegister(FIO_SegDataBlock<r_8>); | 
|---|
|  | 103 | DObjRegister(FIO_SegDataBlock<r_8>, SegDataBlock<r_8>); | 
|---|
|  | 104 | PPRegister(FIO_SegDataBlock< complex<r_4> >); | 
|---|
|  | 105 | DObjRegister(FIO_SegDataBlock< complex<r_4> >, SegDataBlock< complex<r_4> >); | 
|---|
|  | 106 | PPRegister(FIO_SegDataBlock< complex<r_8> >); | 
|---|
|  | 107 | DObjRegister(FIO_SegDataBlock< complex<r_8> >, SegDataBlock< complex<r_8> >); | 
|---|
|  | 108 | PPRegister(FIO_SegDataBlock<string>); | 
|---|
|  | 109 | DObjRegister(FIO_SegDataBlock<string>, SegDataBlock<string>); | 
|---|
| [754] | 110 |  | 
|---|
| [2660] | 111 | // Enregistrement des handlers PPF pour les vecteurs de la STL | 
|---|
|  | 112 | PPRegister(PPFWrapperSTLVector<uint_2>); | 
|---|
|  | 113 | DObjRegister(PPFWrapperSTLVector<uint_2>, std::vector<uint_2>); | 
|---|
|  | 114 | PPRegister(PPFWrapperSTLVector<int_2>); | 
|---|
|  | 115 | DObjRegister(PPFWrapperSTLVector<int_2>, std::vector<int_2>); | 
|---|
|  | 116 | PPRegister(PPFWrapperSTLVector<int_4>); | 
|---|
|  | 117 | DObjRegister(PPFWrapperSTLVector<int_4>, std::vector<int_4>); | 
|---|
|  | 118 | PPRegister(PPFWrapperSTLVector<int_8>); | 
|---|
|  | 119 | DObjRegister(PPFWrapperSTLVector<int_8>, std::vector<int_8>); | 
|---|
|  | 120 | PPRegister(PPFWrapperSTLVector<uint_4>); | 
|---|
|  | 121 | DObjRegister(PPFWrapperSTLVector<uint_4>, std::vector<uint_4>); | 
|---|
|  | 122 | PPRegister(PPFWrapperSTLVector<uint_8>); | 
|---|
|  | 123 | DObjRegister(PPFWrapperSTLVector<uint_8>, std::vector<uint_8>); | 
|---|
|  | 124 | PPRegister(PPFWrapperSTLVector<r_4>); | 
|---|
|  | 125 | DObjRegister(PPFWrapperSTLVector<r_4>, std::vector<r_4>); | 
|---|
|  | 126 | PPRegister(PPFWrapperSTLVector<r_8>); | 
|---|
|  | 127 | DObjRegister(PPFWrapperSTLVector<r_8>, std::vector<r_8>); | 
|---|
|  | 128 | PPRegister(PPFWrapperSTLVector< complex<r_4> >); | 
|---|
|  | 129 | DObjRegister(PPFWrapperSTLVector< complex<r_4> >, std::vector< complex<r_4> >); | 
|---|
|  | 130 | PPRegister(PPFWrapperSTLVector< complex<r_8> >); | 
|---|
|  | 131 | DObjRegister(PPFWrapperSTLVector< complex<r_8> >, std::vector< complex<r_8> >); | 
|---|
|  | 132 | PPRegister(PPFWrapperSTLVector<string>); | 
|---|
|  | 133 | DObjRegister(PPFWrapperSTLVector<string>, std::vector<string>); | 
|---|
|  | 134 |  | 
|---|
|  | 135 |  | 
|---|
| [754] | 136 | #if (!defined(__GNUG__) && !defined(__MWERKS__) && !defined(HPUX)) | 
|---|
|  | 137 | // pas de bufferisation pour printf   cmv 18/3/97 selon E.A. | 
|---|
|  | 138 | // setvbuf(stdout,NULL,_IOLBF,0); setvbuf(stderr,NULL,_IOLBF,0); | 
|---|
|  | 139 | setlinebuf(stdout); | 
|---|
|  | 140 | setlinebuf(stderr); | 
|---|
|  | 141 | #endif | 
|---|
|  | 142 |  | 
|---|
|  | 143 | // si var env SOPHYA_NOPRTVER definie pas de print | 
|---|
|  | 144 | if(!getenv("SOPHYA_NOPRTVER")) Version(true); | 
|---|
|  | 145 |  | 
|---|
|  | 146 | int pnice; | 
|---|
|  | 147 | char* snice = getenv("SOPHYA_NICE"); | 
|---|
|  | 148 | if (!snice) pnice=8; | 
|---|
|  | 149 | else pnice = atoi(snice); | 
|---|
|  | 150 | nice(pnice); | 
|---|
|  | 151 |  | 
|---|
|  | 152 | } | 
|---|
|  | 153 |  | 
|---|
|  | 154 | SophyaInitiator::~SophyaInitiator() | 
|---|
|  | 155 | { | 
|---|
|  | 156 | FgInit--; | 
|---|
|  | 157 | /* | 
|---|
|  | 158 | if (FgInit == 0) | 
|---|
|  | 159 | { | 
|---|
|  | 160 | delete PPersistMgr::classList; PPersistMgr::classList = NULL; | 
|---|
|  | 161 | delete PShPersist::objList;    PShPersist::objList = NULL; | 
|---|
|  | 162 | } | 
|---|
|  | 163 | */ | 
|---|
|  | 164 | } | 
|---|
|  | 165 |  | 
|---|
|  | 166 | double SophyaInitiator::Version(bool fgprt) | 
|---|
|  | 167 | { | 
|---|
|  | 168 | if (fgprt) { | 
|---|
|  | 169 | char* compiler = 0; | 
|---|
|  | 170 | #ifdef __GNUG__ | 
|---|
|  | 171 | compiler = "gcc " __VERSION__; | 
|---|
|  | 172 | #endif | 
|---|
|  | 173 | #ifdef __DECCXX | 
|---|
|  | 174 | compiler = "cxx " ; | 
|---|
|  | 175 | #endif | 
|---|
|  | 176 | #ifdef __aCC__ | 
|---|
|  | 177 | compiler = const_cast<char *>("HP-aCC ") ; | 
|---|
|  | 178 | #endif | 
|---|
|  | 179 | #ifdef __KCC__ | 
|---|
|  | 180 | compiler = const_cast<char *>("KCC ") ; | 
|---|
|  | 181 | #endif | 
|---|
|  | 182 | #ifdef __SGICC__ | 
|---|
| [1249] | 183 | #ifdef SGI_ARCH64 | 
|---|
|  | 184 | compiler = const_cast<char *>("SGI-CC (-64) ") ; | 
|---|
|  | 185 | #else | 
|---|
| [754] | 186 | compiler = const_cast<char *>("SGI-CC ") ; | 
|---|
|  | 187 | #endif | 
|---|
| [1249] | 188 | #endif | 
|---|
| [754] | 189 | #ifdef __MWERKS__ | 
|---|
|  | 190 | compiler = const_cast<char *>("Codewarrior "); | 
|---|
|  | 191 | #endif | 
|---|
|  | 192 | fprintf(stderr,"SOPHYA Version %4.1f Revision %d (%s) -- %s %s %s\n", | 
|---|
|  | 193 | SOPHYA_VERSION, SOPHYA_REVISION, SOPHYA_TAG, | 
|---|
|  | 194 | __DATE__, __TIME__, compiler); | 
|---|
|  | 195 | } | 
|---|
|  | 196 | return(SOPHYA_VERSION + (SOPHYA_REVISION/1000.)); | 
|---|
|  | 197 | } | 
|---|
| [1157] | 198 |  | 
|---|
|  | 199 | double SOPHYA::SophyaVersion() | 
|---|
|  | 200 | { | 
|---|
|  | 201 | return(SOPHYA_VERSION + (SOPHYA_REVISION/1000.)); | 
|---|
|  | 202 | } | 
|---|
| [754] | 203 |  | 
|---|
|  | 204 | // On met un objet initiator en statique, pour les loaders qui savent | 
|---|
|  | 205 | // appeler le constructeur des objets statiques   Reza 08/98 | 
|---|
| [2430] | 206 | #if !defined(Darwin) | 
|---|
|  | 207 | // La presence de l'objet statique psophyainit semble poserun probleme | 
|---|
|  | 208 | // sur MacOSX 10.2 qui se plante a l'initialisation avec les shared-libs | 
|---|
| [754] | 209 | static SophyaInitiator psophyainit; | 
|---|
| [2430] | 210 | #endif | 
|---|