rasdaman complete source
rminit.hh
Go to the documentation of this file.
1 /*
2  * This file is part of rasdaman community.
3  *
4  * Rasdaman community is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Rasdaman community is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16  *
17  * Copyright 2003 - 2010 Peter Baumann / rasdaman GmbH.
18  *
19  * For more information please see <http://www.rasdaman.org>
20  * or contact Peter Baumann via <baumann@rasdaman.com>.
21 */
22 
33 #ifndef _RMINIT_
34 #define _RMINIT_
35 
36 #include <iostream>
37 using std::ios;
38 using std::endl;
39 
40 #include <fstream>
41 #include <raslib/mddtypes.hh>
42 #include <raslib/rm.hh>
43 
44 //@ManMemo: Module: {\bf raslib}
45 
46 /*@Doc:
47 
48  RMANVERSION is the version of the RasDaMan server times 1000 (int).
49  RPCVERSION is the version of the RPC interface times 1000 (int);
50 
51 */
52 
53 //@Man: Version numbers
54 // RMANVERSION now comes in via -DRMANVERSION -- PB 2003-sep-03
55 // const int RMANVERSION = 5100;
56 const int RPCVERSION = 1003;
57 
58 // default rasmgr port
59 const int RASMGRPORT = 7001;
60 
61 // RPC timeout [secs]; used in clientcomm/rpcclientcomm.cc -- PB 2005-sep-09
62 const unsigned int RPC_TIMEOUT = 3;
63 
64 // timeout in RNP communication
65 const unsigned int RNP_COMM_TIMEOUT = 60;
66 
67 // timeout in nerver.cc
68 const unsigned int RNP_TIMEOUT_LISTEN = 30;
69 
70 // maximum number of retries in rnprotocol/rnpclientcomm2.cc
71 const unsigned int RNP_MAX_RETRY = 10;
72 
73 //@ManMemo: Module: {\bf raslib}
74 
75 /*@Doc:
76 
77  Class {\tt RMInit} is supposed to be instantiated just once. The scope
78  of this instance is equal to the program scope (global variable)
79  and therefore lifetime of the {\tt RMInit} instance and the application
80  are the same. The constructor is used to allocate ressources needed
81  during the whole application and the destructor cleans up memory at
82  the end of the application.
83 
84  */
85 
90 class RMInit : public RM_Class
91 {
92 public:
94  RMInit( char applicationType );
95 
97  ~RMInit();
98 
100  static std::ostream logOut;
101 
103  static std::ostream dbgOut;
104 
106  static std::ostream bmOut;
107 
109  static std::ofstream logFileOut;
110 
112  static std::ofstream dbgFileOut;
113 
115  static std::ofstream bmFileOut;
116 
118  static char* userName;
119 
121  static bool useTileContainer;
122 
124  static bool tiling;
125 
127  static unsigned long timeOut;
128 
130  static bool noTimeOut;
131 
133 
134  static unsigned int clientcommMaxRetry;
135 
136  static unsigned int clientcommSleep;
137 
138  static unsigned int rpcMaxRetry;
139 
140 private:
142  int checkOptionString( const char* optString, const char* option, char* &value );
150  char applicationType;
152 };
153 
154 // Macro for initialization of static members and creation of global RMInit instance
155 // ---------------------------------------------------------------------------------
156 // The macro has to be invoked exactly once in each executable using raslib.
157 //
158 // rasserver -> in servercomm.o
159 // rasdaman clients -> in clientcomm.o
160 // test programms without clientcomm.o and servercomm.o -> in main.o
161 //
162 // The reason is that initialisation of globals can be initialized in any
163 // order if they are in different files. Only in one file the order is defined.
164 // As it is implemented now, the streams have to be defined somewhere. This
165 // could easily be done in rminit.cc. But the call to the constructor of RMInit
166 // has to get a flag for client ('C') or server ('S') as a parameter. This has
167 // be done somewhere else. In that case the constructor may be called before
168 // initialization of the streams, the program crashes! If all initialisations
169 // are in the same file, the order is defined. That is what this macro is for.
170 //
171 // Note: At some point it may be useful to reimplement this mess.
172 
173 #define RMINITGLOBALS( appMode ) std::ostream RMInit::logOut(std::cout.rdbuf()); \
174  std::ostream RMInit::dbgOut(std::cout.rdbuf()); \
175  std::ostream RMInit::bmOut(std::cout.rdbuf()); \
176  std::ofstream RMInit::logFileOut; \
177  std::ofstream RMInit::dbgFileOut; \
178  std::ofstream RMInit::bmFileOut; \
179  RMInit rmInit( appMode );
180 
181 #endif
static std::ostream logOut
output stream for log information
Definition: rminit.hh:100
Definition: rminit.hh:90
static std::ostream dbgOut
output stream for debug information
Definition: rminit.hh:103
const unsigned int RNP_TIMEOUT_LISTEN
Definition: rminit.hh:68
static std::ofstream bmFileOut
file output for benchmark information
Definition: rminit.hh:115
~RMInit()
destructor
static unsigned int clientcommMaxRetry
Definition: rminit.hh:134
static unsigned int rpcMaxRetry
Definition: rminit.hh:138
Definition: rm.hh:36
const unsigned int RPC_TIMEOUT
Definition: rminit.hh:62
static std::ofstream dbgFileOut
file output for debug information
Definition: rminit.hh:112
static bool useTileContainer
use inlinetiles and inlinetile container index
Definition: rminit.hh:121
static bool noTimeOut
flag, if time out checking is enabled (causes sometimes problems because of signal handler) ...
Definition: rminit.hh:130
static std::ofstream logFileOut
file output for log information
Definition: rminit.hh:109
static char * userName
name of the user
Definition: rminit.hh:118
static r_Bytes clientTileSize
Definition: rminit.hh:132
static unsigned long timeOut
specifies time out in seconds
Definition: rminit.hh:127
static unsigned int clientcommSleep
Definition: rminit.hh:136
RMInit(char applicationType)
constructor
unsigned int r_Bytes
Definition: mddtypes.hh:56
const int RPCVERSION
Definition: rminit.hh:56
const unsigned int RNP_COMM_TIMEOUT
Definition: rminit.hh:65
static std::ostream bmOut
output stream for benchmark information
Definition: rminit.hh:106
const int RASMGRPORT
Definition: rminit.hh:59
const unsigned int RNP_MAX_RETRY
Definition: rminit.hh:71
static bool tiling
switch for turning on/off tiling
Definition: rminit.hh:124