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

Last change on this file since 2615 was 2615, checked in by cmv, 21 years ago

using namespace sophya enleve de machdefs.h, nouveau sopnamsp.h cmv 10/09/2004

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