[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 | \class SOPHYA::SophyaInitiator
|
---|
[1607] | 28 | \ingroup BaseTools
|
---|
[913] | 29 | Each Sophya module may contain an initialiser class which should
|
---|
| 30 | be a sub-class of SophyaInitiator.
|
---|
| 31 | */
|
---|
| 32 |
|
---|
[754] | 33 | SophyaInitiator::SophyaInitiator()
|
---|
| 34 | {
|
---|
| 35 | FgInit++;
|
---|
| 36 | if (FgInit > 1) return;
|
---|
| 37 |
|
---|
| 38 | InitFailNewHandler();
|
---|
| 39 |
|
---|
| 40 | #ifdef xx__mac__
|
---|
| 41 | //InitToolBox();
|
---|
| 42 | //SIOUXSettings.initializeTB = FALSE;
|
---|
| 43 | SIOUXSettings.autocloseonquit = FALSE;
|
---|
| 44 | SIOUXSettings.asktosaveonclose = FALSE;
|
---|
| 45 | SIOUXSettings.showstatusline = TRUE;
|
---|
| 46 | #endif
|
---|
| 47 |
|
---|
| 48 | PIOPersist::Initialize();
|
---|
| 49 | PPRegister(FIO_NDataBlock<uint_1>);
|
---|
[802] | 50 | DObjRegister(FIO_NDataBlock<uint_1>, NDataBlock<uint_1>);
|
---|
[754] | 51 | PPRegister(FIO_NDataBlock<uint_2>);
|
---|
[802] | 52 | DObjRegister(FIO_NDataBlock<uint_2>, NDataBlock<uint_2>);
|
---|
[754] | 53 | PPRegister(FIO_NDataBlock<int_2>);
|
---|
[802] | 54 | DObjRegister(FIO_NDataBlock<int_2>, NDataBlock<int_2>);
|
---|
[754] | 55 | PPRegister(FIO_NDataBlock<int_4>);
|
---|
[802] | 56 | DObjRegister(FIO_NDataBlock<int_4>, NDataBlock<int_4>);
|
---|
[754] | 57 | PPRegister(FIO_NDataBlock<int_8>);
|
---|
[802] | 58 | DObjRegister(FIO_NDataBlock<int_8>, NDataBlock<int_8>);
|
---|
[754] | 59 | PPRegister(FIO_NDataBlock<uint_4>);
|
---|
[802] | 60 | DObjRegister(FIO_NDataBlock<uint_4>, NDataBlock<uint_4>);
|
---|
[754] | 61 | PPRegister(FIO_NDataBlock<uint_8>);
|
---|
[802] | 62 | DObjRegister(FIO_NDataBlock<uint_8>, NDataBlock<uint_8>);
|
---|
[754] | 63 | PPRegister(FIO_NDataBlock<r_4>);
|
---|
[802] | 64 | DObjRegister(FIO_NDataBlock<r_4>, NDataBlock<r_4>);
|
---|
[754] | 65 | PPRegister(FIO_NDataBlock<r_8>);
|
---|
[802] | 66 | DObjRegister(FIO_NDataBlock<r_8>, NDataBlock<r_8>);
|
---|
| 67 | PPRegister(FIO_NDataBlock< complex<r_4> >);
|
---|
| 68 | DObjRegister(FIO_NDataBlock< complex<r_4> >, NDataBlock< complex<r_4> >);
|
---|
| 69 | PPRegister(FIO_NDataBlock< complex<r_8> >);
|
---|
| 70 | DObjRegister(FIO_NDataBlock< complex<r_8> >, NDataBlock< complex<r_8> >);
|
---|
[754] | 71 |
|
---|
| 72 | PPRegister(ObjFileIO<DVList>);
|
---|
[802] | 73 | DObjRegister(ObjFileIO<DVList>, DVList);
|
---|
[754] | 74 |
|
---|
| 75 |
|
---|
| 76 | #if (!defined(__GNUG__) && !defined(__MWERKS__) && !defined(HPUX))
|
---|
| 77 | // pas de bufferisation pour printf cmv 18/3/97 selon E.A.
|
---|
| 78 | // setvbuf(stdout,NULL,_IOLBF,0); setvbuf(stderr,NULL,_IOLBF,0);
|
---|
| 79 | setlinebuf(stdout);
|
---|
| 80 | setlinebuf(stderr);
|
---|
| 81 | #endif
|
---|
| 82 |
|
---|
| 83 | // si var env SOPHYA_NOPRTVER definie pas de print
|
---|
| 84 | if(!getenv("SOPHYA_NOPRTVER")) Version(true);
|
---|
| 85 |
|
---|
| 86 | int pnice;
|
---|
| 87 | char* snice = getenv("SOPHYA_NICE");
|
---|
| 88 | if (!snice) pnice=8;
|
---|
| 89 | else pnice = atoi(snice);
|
---|
| 90 | nice(pnice);
|
---|
| 91 |
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | SophyaInitiator::~SophyaInitiator()
|
---|
| 95 | {
|
---|
| 96 | FgInit--;
|
---|
| 97 | /*
|
---|
| 98 | if (FgInit == 0)
|
---|
| 99 | {
|
---|
| 100 | delete PPersistMgr::classList; PPersistMgr::classList = NULL;
|
---|
| 101 | delete PShPersist::objList; PShPersist::objList = NULL;
|
---|
| 102 | }
|
---|
| 103 | */
|
---|
| 104 | }
|
---|
| 105 |
|
---|
| 106 | double SophyaInitiator::Version(bool fgprt)
|
---|
| 107 | {
|
---|
| 108 | if (fgprt) {
|
---|
| 109 | char* compiler = 0;
|
---|
| 110 | #ifdef __GNUG__
|
---|
| 111 | compiler = "gcc " __VERSION__;
|
---|
| 112 | #endif
|
---|
| 113 | #ifdef __DECCXX
|
---|
| 114 | compiler = "cxx " ;
|
---|
| 115 | #endif
|
---|
| 116 | #ifdef __aCC__
|
---|
| 117 | compiler = const_cast<char *>("HP-aCC ") ;
|
---|
| 118 | #endif
|
---|
| 119 | #ifdef __KCC__
|
---|
| 120 | compiler = const_cast<char *>("KCC ") ;
|
---|
| 121 | #endif
|
---|
| 122 | #ifdef __SGICC__
|
---|
[1249] | 123 | #ifdef SGI_ARCH64
|
---|
| 124 | compiler = const_cast<char *>("SGI-CC (-64) ") ;
|
---|
| 125 | #else
|
---|
[754] | 126 | compiler = const_cast<char *>("SGI-CC ") ;
|
---|
| 127 | #endif
|
---|
[1249] | 128 | #endif
|
---|
[754] | 129 | #ifdef __MWERKS__
|
---|
| 130 | compiler = const_cast<char *>("Codewarrior ");
|
---|
| 131 | #endif
|
---|
| 132 | fprintf(stderr,"SOPHYA Version %4.1f Revision %d (%s) -- %s %s %s\n",
|
---|
| 133 | SOPHYA_VERSION, SOPHYA_REVISION, SOPHYA_TAG,
|
---|
| 134 | __DATE__, __TIME__, compiler);
|
---|
| 135 | }
|
---|
| 136 | return(SOPHYA_VERSION + (SOPHYA_REVISION/1000.));
|
---|
| 137 | }
|
---|
[1157] | 138 |
|
---|
| 139 | double SOPHYA::SophyaVersion()
|
---|
| 140 | {
|
---|
| 141 | return(SOPHYA_VERSION + (SOPHYA_REVISION/1000.));
|
---|
| 142 | }
|
---|
[754] | 143 |
|
---|
| 144 | // On met un objet initiator en statique, pour les loaders qui savent
|
---|
| 145 | // appeler le constructeur des objets statiques Reza 08/98
|
---|
| 146 | static SophyaInitiator psophyainit;
|
---|