| [754] | 1 | #include "machdefs.h" | 
|---|
|  | 2 |  | 
|---|
|  | 3 | #include <unistd.h> | 
|---|
|  | 4 | #include <stdlib.h> | 
|---|
|  | 5 | #include <stdio.h> | 
|---|
|  | 6 | #include <complex> | 
|---|
|  | 7 |  | 
|---|
|  | 8 | #include "sophyainit.h" | 
|---|
|  | 9 |  | 
|---|
|  | 10 | #include "pexceptions.h" | 
|---|
|  | 11 |  | 
|---|
|  | 12 | #include "ppersist.h" | 
|---|
| [802] | 13 | #include "fiondblock.h" | 
|---|
| [754] | 14 | #include "dvlist.h" | 
|---|
|  | 15 |  | 
|---|
|  | 16 | #include "sversion.h" | 
|---|
|  | 17 |  | 
|---|
|  | 18 | // ---  Classe d'initialisation de SOPHYA, (PPersistMgr en particulier) | 
|---|
|  | 19 | int SophyaInitiator::FgInit = 0; | 
|---|
|  | 20 |  | 
|---|
| [913] | 21 | /*! | 
|---|
|  | 22 | \namespace SOPHYA | 
|---|
|  | 23 | \brief This is the namespace for the whole Sophya package | 
|---|
|  | 24 | */ | 
|---|
|  | 25 |  | 
|---|
|  | 26 | /*! | 
|---|
|  | 27 | \defgroup SysTools SysTools module | 
|---|
|  | 28 | This module contains classes and functions which define the | 
|---|
|  | 29 | general framework for \b Sophya package such as the simple | 
|---|
|  | 30 | persistence, serialisation mechanism through \b PPersist, | 
|---|
|  | 31 | \b POutPersist, \b PInPersist classes. It contains also | 
|---|
|  | 32 | few utility classes such as the \b NDataBlock<T>, (template | 
|---|
|  | 33 | numerical arrays with reference counting and sharing) | 
|---|
|  | 34 | \b DataCards and \b PDynLinker (Dynamic link handler) classes. | 
|---|
|  | 35 |  | 
|---|
|  | 36 | */ | 
|---|
|  | 37 |  | 
|---|
|  | 38 | /*! | 
|---|
|  | 39 | \class SOPHYA::SophyaInitiator | 
|---|
|  | 40 | \ingroup SysTools | 
|---|
|  | 41 | Each Sophya module may contain an initialiser class which should | 
|---|
|  | 42 | be a sub-class of SophyaInitiator. | 
|---|
|  | 43 | */ | 
|---|
|  | 44 |  | 
|---|
| [754] | 45 | SophyaInitiator::SophyaInitiator() | 
|---|
|  | 46 | { | 
|---|
|  | 47 | FgInit++; | 
|---|
|  | 48 | if (FgInit > 1)  return; | 
|---|
|  | 49 |  | 
|---|
|  | 50 | InitFailNewHandler(); | 
|---|
|  | 51 |  | 
|---|
|  | 52 | #ifdef xx__mac__ | 
|---|
|  | 53 | //InitToolBox(); | 
|---|
|  | 54 | //SIOUXSettings.initializeTB = FALSE; | 
|---|
|  | 55 | SIOUXSettings.autocloseonquit = FALSE; | 
|---|
|  | 56 | SIOUXSettings.asktosaveonclose = FALSE; | 
|---|
|  | 57 | SIOUXSettings.showstatusline = TRUE; | 
|---|
|  | 58 | #endif | 
|---|
|  | 59 |  | 
|---|
|  | 60 | PIOPersist::Initialize(); | 
|---|
|  | 61 | PPRegister(FIO_NDataBlock<uint_1>); | 
|---|
| [802] | 62 | DObjRegister(FIO_NDataBlock<uint_1>, NDataBlock<uint_1>); | 
|---|
| [754] | 63 | PPRegister(FIO_NDataBlock<uint_2>); | 
|---|
| [802] | 64 | DObjRegister(FIO_NDataBlock<uint_2>, NDataBlock<uint_2>); | 
|---|
| [754] | 65 | PPRegister(FIO_NDataBlock<int_2>); | 
|---|
| [802] | 66 | DObjRegister(FIO_NDataBlock<int_2>, NDataBlock<int_2>); | 
|---|
| [754] | 67 | PPRegister(FIO_NDataBlock<int_4>); | 
|---|
| [802] | 68 | DObjRegister(FIO_NDataBlock<int_4>, NDataBlock<int_4>); | 
|---|
| [754] | 69 | PPRegister(FIO_NDataBlock<int_8>); | 
|---|
| [802] | 70 | DObjRegister(FIO_NDataBlock<int_8>, NDataBlock<int_8>); | 
|---|
| [754] | 71 | PPRegister(FIO_NDataBlock<uint_4>); | 
|---|
| [802] | 72 | DObjRegister(FIO_NDataBlock<uint_4>, NDataBlock<uint_4>); | 
|---|
| [754] | 73 | PPRegister(FIO_NDataBlock<uint_8>); | 
|---|
| [802] | 74 | DObjRegister(FIO_NDataBlock<uint_8>, NDataBlock<uint_8>); | 
|---|
| [754] | 75 | PPRegister(FIO_NDataBlock<r_4>); | 
|---|
| [802] | 76 | DObjRegister(FIO_NDataBlock<r_4>, NDataBlock<r_4>); | 
|---|
| [754] | 77 | PPRegister(FIO_NDataBlock<r_8>); | 
|---|
| [802] | 78 | DObjRegister(FIO_NDataBlock<r_8>, NDataBlock<r_8>); | 
|---|
|  | 79 | PPRegister(FIO_NDataBlock< complex<r_4> >); | 
|---|
|  | 80 | DObjRegister(FIO_NDataBlock< complex<r_4> >, NDataBlock< complex<r_4> >); | 
|---|
|  | 81 | PPRegister(FIO_NDataBlock< complex<r_8> >); | 
|---|
|  | 82 | DObjRegister(FIO_NDataBlock< complex<r_8> >, NDataBlock< complex<r_8> >); | 
|---|
| [754] | 83 |  | 
|---|
|  | 84 | PPRegister(ObjFileIO<DVList>); | 
|---|
| [802] | 85 | DObjRegister(ObjFileIO<DVList>, DVList); | 
|---|
| [754] | 86 |  | 
|---|
|  | 87 |  | 
|---|
|  | 88 | #if (!defined(__GNUG__) && !defined(__MWERKS__) && !defined(HPUX)) | 
|---|
|  | 89 | // pas de bufferisation pour printf   cmv 18/3/97 selon E.A. | 
|---|
|  | 90 | // setvbuf(stdout,NULL,_IOLBF,0); setvbuf(stderr,NULL,_IOLBF,0); | 
|---|
|  | 91 | setlinebuf(stdout); | 
|---|
|  | 92 | setlinebuf(stderr); | 
|---|
|  | 93 | #endif | 
|---|
|  | 94 |  | 
|---|
|  | 95 | // si var env SOPHYA_NOPRTVER definie pas de print | 
|---|
|  | 96 | if(!getenv("SOPHYA_NOPRTVER")) Version(true); | 
|---|
|  | 97 |  | 
|---|
|  | 98 | int pnice; | 
|---|
|  | 99 | char* snice = getenv("SOPHYA_NICE"); | 
|---|
|  | 100 | if (!snice) pnice=8; | 
|---|
|  | 101 | else pnice = atoi(snice); | 
|---|
|  | 102 | nice(pnice); | 
|---|
|  | 103 |  | 
|---|
|  | 104 | } | 
|---|
|  | 105 |  | 
|---|
|  | 106 | SophyaInitiator::~SophyaInitiator() | 
|---|
|  | 107 | { | 
|---|
|  | 108 | FgInit--; | 
|---|
|  | 109 | /* | 
|---|
|  | 110 | if (FgInit == 0) | 
|---|
|  | 111 | { | 
|---|
|  | 112 | delete PPersistMgr::classList; PPersistMgr::classList = NULL; | 
|---|
|  | 113 | delete PShPersist::objList;    PShPersist::objList = NULL; | 
|---|
|  | 114 | } | 
|---|
|  | 115 | */ | 
|---|
|  | 116 | } | 
|---|
|  | 117 |  | 
|---|
|  | 118 | double SophyaInitiator::Version(bool fgprt) | 
|---|
|  | 119 | { | 
|---|
|  | 120 | if (fgprt) { | 
|---|
|  | 121 | char* compiler = 0; | 
|---|
|  | 122 | #ifdef __GNUG__ | 
|---|
|  | 123 | compiler = "gcc " __VERSION__; | 
|---|
|  | 124 | #endif | 
|---|
|  | 125 | #ifdef __DECCXX | 
|---|
|  | 126 | compiler = "cxx " ; | 
|---|
|  | 127 | #endif | 
|---|
|  | 128 | #ifdef __aCC__ | 
|---|
|  | 129 | compiler = const_cast<char *>("HP-aCC ") ; | 
|---|
|  | 130 | #endif | 
|---|
|  | 131 | #ifdef __KCC__ | 
|---|
|  | 132 | compiler = const_cast<char *>("KCC ") ; | 
|---|
|  | 133 | #endif | 
|---|
|  | 134 | #ifdef __SGICC__ | 
|---|
|  | 135 | compiler = const_cast<char *>("SGI-CC ") ; | 
|---|
|  | 136 | #endif | 
|---|
|  | 137 | #ifdef __MWERKS__ | 
|---|
|  | 138 | compiler = const_cast<char *>("Codewarrior "); | 
|---|
|  | 139 | #endif | 
|---|
|  | 140 | fprintf(stderr,"SOPHYA Version %4.1f Revision %d (%s) -- %s %s %s\n", | 
|---|
|  | 141 | SOPHYA_VERSION, SOPHYA_REVISION, SOPHYA_TAG, | 
|---|
|  | 142 | __DATE__, __TIME__, compiler); | 
|---|
|  | 143 | } | 
|---|
|  | 144 | return(SOPHYA_VERSION + (SOPHYA_REVISION/1000.)); | 
|---|
|  | 145 | } | 
|---|
|  | 146 |  | 
|---|
|  | 147 | // On met un objet initiator en statique, pour les loaders qui savent | 
|---|
|  | 148 | // appeler le constructeur des objets statiques   Reza 08/98 | 
|---|
|  | 149 | static SophyaInitiator psophyainit; | 
|---|