Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

baciDB.h

Go to the documentation of this file.
00001 #ifndef baciDB_H 00002 #define baciDB_H 00003 00004 /******************************************************************* 00005 * ALMA - Atacama Large Millimiter Array 00006 * (c) European Southern Observatory, 2003 00007 * 00008 *This library is free software; you can redistribute it and/or 00009 *modify it under the terms of the GNU Lesser General Public 00010 *License as published by the Free Software Foundation; either 00011 *version 2.1 of the License, or (at your option) any later version. 00012 * 00013 *This library is distributed in the hope that it will be useful, 00014 *but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 *Lesser General Public License for more details. 00017 * 00018 *You should have received a copy of the GNU Lesser General Public 00019 *License along with this library; if not, write to the Free Software 00020 *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 * 00022 * "@(#) $Id: baciDB.h,v 1.99 2008/10/01 02:26:45 cparedes Exp $" 00023 * 00024 * who when what 00025 * -------- ---------- ---------------------------------------------- 00026 * msekoran 2001/06/23 redesigned to OO design 00027 * msekoran 2001/03/07 modified 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 /* ------------------ [ CharacteristicModel interface ] ------------------ */ 00095 00096 /* 00097 * @throw ACS::NoSuchCharacteristic 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 /* baciDB_H */ 00183 00184 00185

Generated on Thu Apr 30 02:30:50 2009 for ACS C++ API by doxygen 1.3.8