source: Sophya/trunk/SophyaLib/BaseTools/sophyainit.cc@ 3007

Last change on this file since 3007 was 2830, checked in by ansari, 20 years ago

Amelioration classe TimeStamp - prise en charge format YYYY-MM-DDThh:mm:ss
et TimeStamp rendu PPersist - Reza 8/11/2005

File size: 7.1 KB
Line 
1#include "sopnamsp.h"
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"
14#include "fiondblock.h"
15#include "dvlist.h"
16
17#include "fiosegdb.h"
18#include "ppfwrapstlv.h"
19
20#include "sversion.h"
21
22// --- Classe d'initialisation de SOPHYA, (PPersistMgr en particulier)
23int SophyaInitiator::FgInit = 0;
24
25/*!
26 \namespace SOPHYA
27 \brief This is the namespace for the whole Sophya package
28*/
29
30/*!
31 \class SOPHYA::SophyaInitiator
32 \ingroup BaseTools
33 Each Sophya module may contain an initialiser class which should
34 be a sub-class of SophyaInitiator.
35*/
36
37SophyaInitiator::SophyaInitiator()
38{
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
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
57 // Initialisation des mecanismes PPF I/O
58 PIOPersist::Initialize();
59 // Enregistrement des handlers PPF pour les NDataBlock<T>
60 PPRegister(FIO_NDataBlock<uint_1>);
61 DObjRegister(FIO_NDataBlock<uint_1>, NDataBlock<uint_1>);
62 PPRegister(FIO_NDataBlock<uint_2>);
63 DObjRegister(FIO_NDataBlock<uint_2>, NDataBlock<uint_2>);
64 PPRegister(FIO_NDataBlock<int_2>);
65 DObjRegister(FIO_NDataBlock<int_2>, NDataBlock<int_2>);
66 PPRegister(FIO_NDataBlock<int_4>);
67 DObjRegister(FIO_NDataBlock<int_4>, NDataBlock<int_4>);
68 PPRegister(FIO_NDataBlock<int_8>);
69 DObjRegister(FIO_NDataBlock<int_8>, NDataBlock<int_8>);
70 PPRegister(FIO_NDataBlock<uint_4>);
71 DObjRegister(FIO_NDataBlock<uint_4>, NDataBlock<uint_4>);
72 PPRegister(FIO_NDataBlock<uint_8>);
73 DObjRegister(FIO_NDataBlock<uint_8>, NDataBlock<uint_8>);
74 PPRegister(FIO_NDataBlock<r_4>);
75 DObjRegister(FIO_NDataBlock<r_4>, NDataBlock<r_4>);
76 PPRegister(FIO_NDataBlock<r_8>);
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> >);
82
83 // Enregistrement des handlers PPF pour les TimeStamp
84 PPRegister(ObjFileIO<TimeStamp>);
85 DObjRegister(ObjFileIO<TimeStamp>, TimeStamp);
86
87 // Enregistrement des handlers PPF pour les DVList
88 PPRegister(ObjFileIO<DVList>);
89 DObjRegister(ObjFileIO<DVList>, DVList);
90
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>);
114
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> >);
136 PPRegister(PPFWrapperSTLVector< string >);
137 DObjRegister(PPFWrapperSTLVector< string >, std::vector<string>);
138
139 PPRegister(PPFWrapperSTLVector< TimeStamp >);
140 DObjRegister(PPFWrapperSTLVector< TimeStamp >, std::vector<TimeStamp>);
141
142
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
161SophyaInitiator::~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
173double SophyaInitiator::Version(bool fgprt)
174{
175if (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__
190 #ifdef SGI_ARCH64
191 compiler = const_cast<char *>("SGI-CC (-64) ") ;
192 #else
193 compiler = const_cast<char *>("SGI-CC ") ;
194 #endif
195 #endif
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}
203return(SOPHYA_VERSION + (SOPHYA_REVISION/1000.));
204}
205
206double SOPHYA::SophyaVersion()
207{
208return(SOPHYA_VERSION + (SOPHYA_REVISION/1000.));
209}
210
211// On met un objet initiator en statique, pour les loaders qui savent
212// appeler le constructeur des objets statiques Reza 08/98
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
216static SophyaInitiator psophyainit;
217#endif
Note: See TracBrowser for help on using the repository browser.