Go to the documentation of this file.00001 #ifndef baciDB_H
00002 #define baciDB_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00035 #ifndef __cplusplus
00036 #error This is a C++ include file and cannot be used from plain C
00037 #endif
00038
00039 #include <acsutil.h>
00040 #include <baciExport.h>
00041 #include <ace/SString.h>
00042 #include <tao/corba.h>
00043
00044 #include <baciC.h>
00045 #include <acsutilWildcard.h>
00046 #include <baciCDBPropertySet.h>
00047
00048 #include <cdb.h>
00049
00050 namespace baci {
00051
00052 class baci_EXPORT DBConnector
00053 {
00054
00055 public:
00056
00058 static bool initDB(const ACE_CString& dbPrefix, int argc = 0, char** argv = NULL, CORBA::ORB_ptr orb = CORBA::ORB::_nil())
00059 {
00060 dbPrefix_m = dbPrefix;
00061 dbTable_mp = cdb::getDatabase(argc, argv, orb);
00062
00063 return (dbTable_mp!=0);
00064 }
00065
00066
00068 static void closeDB()
00069 {
00070 if (dbTable_mp!=0)
00071 {
00072 destroyDatabase(dbTable_mp);
00073 dbTable_mp = 0;
00074 }
00075 }
00076
00078 static ACE_CString getFullAddress(const ACE_CString& address)
00079 {
00080 return dbPrefix_m+"/"+address;
00081 };
00082
00084 static cdb::Table * getDBTable()
00085 {
00086 return dbTable_mp;
00087 }
00088
00089
00093
00094
00095
00096
00097
00098
00099 static CORBA::Any * get_characteristic_by_name (
00100 const ACE_CString& objectName,
00101 const char * name
00102
00103 );
00104
00105 static ACS::stringSeq * find_characteristic (
00106 const ACE_CString& name,
00107 const char * reg_exp
00108
00109 );
00110
00111 static CosPropertyService::PropertySet_ptr get_all_characteristics (
00112 const ACE_CString& name
00113
00114 );
00115
00116
00117
00118
00122 static void writeCommand(ACE_CString deviceName, ACE_CString commandDesc, ACE_CString commandTimestamp);
00123
00125 static void writeString(ACE_CString name, const ACE_CString& value);
00126
00128 static void writeDouble(ACE_CString name, CORBA::Double value);
00129
00131 static void writeLong(ACE_CString name, CORBA::Long value);
00132
00134 static void writeULong(ACE_CString name, CORBA::ULong value);
00135
00137 static void writeDoubleSeq(ACE_CString name, const ACS::doubleSeq & val);
00138
00140 static void writeLongSeq(ACE_CString name, const ACS::longSeq & val);
00141
00143 static ACE_CString readString(ACE_CString name);
00144
00146 static CORBA::Double readDouble(ACE_CString name);
00147
00149 static ACS::doubleSeq readDoubleSeq(ACE_CString name);
00150
00152 static ACS::longSeq readLongSeq(ACE_CString name);
00153
00155 static CORBA::Long readLong(ACE_CString name);
00156
00158 static CORBA::ULong readULong(ACE_CString name);
00159
00160 private:
00161
00163 static ACE_CString dbPrefix_m;
00164
00166 static cdb::Table * dbTable_mp;
00167
00171 void operator=(const DBConnector&);
00172
00176 DBConnector(const DBConnector&);
00177
00178 };
00179
00180 };
00181
00182 #endif
00183
00184
00185