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