00001
00002
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
00030
00036 #ifndef OW_BinarySerialization_HPP_
00037 #define OW_BinarySerialization_HPP_
00038 #include "OW_config.h"
00039 #include "OW_Types.hpp"
00040 #include "OW_CIMFwd.hpp"
00041 #include "OW_Bool.hpp"
00042 #include "OW_CIMObjectPath.hpp"
00043 #include "OW_CIMNameSpace.hpp"
00044 #include "OW_CIMClass.hpp"
00045 #include "OW_CIMInstance.hpp"
00046 #include "OW_CIMQualifierType.hpp"
00047 #include "OW_CIMValue.hpp"
00048 #include "OW_ByteSwap.hpp"
00049 #include "OW_IfcsFwd.hpp"
00050
00051 #if defined(OW_HAVE_OSTREAM) && defined(OW_HAVE_ISTREAM)
00052 #include <ostream>
00053 #include <istream>
00054 #else
00055 #include <iostream>
00056 #endif
00057
00058
00059
00060
00061 namespace OW_NAMESPACE
00062 {
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 const UInt32 BinaryProtocolVersion = 3000008;
00084
00085
00086 const UInt32 MinBinaryProtocolVersion = 3000007;
00087
00088
00089 const UInt8 BIN_OK = 0;
00090 const UInt8 BIN_ERROR = 1;
00091 const UInt8 BIN_EXCEPTION = 2;
00092 const UInt8 IPC_AUTHENTICATE = 10;
00093 const UInt8 IPC_FUNCTIONCALL = 11;
00094 const UInt8 IPC_CLOSECONN = 12;
00095 const UInt8 BIN_DELETECLS = 20;
00096 const UInt8 BIN_DELETEINST = 21;
00097 const UInt8 BIN_DELETEQUAL = 22;
00098 const UInt8 BIN_ENUMCLSS = 23;
00099 const UInt8 BIN_ENUMCLSNAMES = 24;
00100 const UInt8 BIN_ENUMINSTS = 25;
00101 const UInt8 BIN_ENUMINSTNAMES = 26;
00102 const UInt8 BIN_ENUMQUALS = 27;
00103 const UInt8 BIN_GETCLS = 28;
00104 const UInt8 BIN_GETINST = 29;
00105 const UInt8 BIN_INVMETH = 30;
00106 const UInt8 BIN_GETQUAL = 31;
00107 const UInt8 BIN_SETQUAL = 32;
00108 const UInt8 BIN_MODIFYCLS = 33;
00109 const UInt8 BIN_CREATECLS = 34;
00110 const UInt8 BIN_MODIFYINST = 35;
00111 const UInt8 BIN_CREATEINST = 36;
00112 const UInt8 BIN_GETPROP = 37;
00113 const UInt8 BIN_SETPROP = 38;
00114 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00115 const UInt8 BIN_ASSOCNAMES = 39;
00116 const UInt8 BIN_ASSOCIATORS = 40;
00117 const UInt8 BIN_REFNAMES = 41;
00118 const UInt8 BIN_REFERENCES = 42;
00119 #endif
00120 const UInt8 BIN_EXECQUERY = 43;
00121 const UInt8 BIN_GETSVRFEATURES = 44;
00122 const UInt8 BINSIG_NS = 100;
00123 const UInt8 BINSIG_OP = 101;
00124 const UInt8 BINSIG_CLS = 102;
00125 const UInt8 BINSIG_INST = 103;
00126 const UInt8 BINSIG_BOOL = 104;
00127 const UInt8 BINSIG_CLSENUM = 105;
00128 const UInt8 BINSIG_STR = 106;
00129 const UInt8 BINSIG_STRARRAY = 107;
00130 const UInt8 BINSIG_QUAL_TYPE = 108;
00131 const UInt8 BINSIG_VALUE = 109;
00132 const UInt8 BINSIG_OPENUM = 110;
00133 const UInt8 BINSIG_INSTENUM = 111;
00134 const UInt8 BINSIG_QUAL_TYPEENUM = 112;
00135 const UInt8 BINSIG_VALUEARRAY = 113;
00136 const UInt8 BINSIG_PARAMVALUEARRAY = 114;
00137 const UInt8 BINSIG_STRINGENUM = 115;
00138 const UInt8 END_CLSENUM = 150;
00139 const UInt8 END_OPENUM = 151;
00140 const UInt8 END_INSTENUM = 152;
00141 const UInt8 END_QUALENUM = 153;
00142 const UInt8 END_STRINGENUM = 154;
00144 namespace BinarySerialization
00145 {
00146 OW_COMMON_API void write(std::ostream& ostrm, const void* dataOut,
00147 int dataOutLen);
00148 OW_COMMON_API void verifySignature(std::istream& istrm, UInt8 validSig);
00149 inline void write(std::ostream& ostrm, Int32 val)
00150 {
00151 val = hton32(val);
00152 BinarySerialization::write(ostrm, &val, sizeof(val));
00153 }
00154 inline void write(std::ostream& ostrm, UInt32 val)
00155 {
00156 val = hton32(val);
00157 BinarySerialization::write(ostrm, &val, sizeof(val));
00158 }
00159 OW_COMMON_API void writeLen(std::ostream& ostrm, UInt32 len);
00160 inline void write(std::ostream& ostrm, UInt8 val)
00161 {
00162 BinarySerialization::write(ostrm, &val, sizeof(val));
00163 }
00164 inline void write(std::ostream& ostrm, UInt16 val)
00165 {
00166 val = hton16(val);
00167 BinarySerialization::write(ostrm, &val, sizeof(val));
00168 }
00169 inline void write(std::ostream& ostrm, Int16 val)
00170 {
00171 val = hton16(val);
00172 BinarySerialization::write(ostrm, &val, sizeof(val));
00173 }
00174 inline void write(std::ostream& ostrm, const String& str)
00175 {
00176 str.writeObject(ostrm);
00177 }
00178 inline void writeObject(std::ostream& ostrm, UInt8 sig,
00179 const CIMBase& obj)
00180 {
00181 obj.writeObject(ostrm);
00182 }
00183 inline void writeObjectPath(std::ostream& ostrm,
00184 const CIMObjectPath& op)
00185 {
00186 BinarySerialization::writeObject(ostrm, BINSIG_OP, op);
00187 }
00188 inline void writeNameSpace(std::ostream& ostrm,
00189 const CIMNameSpace& ns)
00190 {
00191 BinarySerialization::writeObject(ostrm, BINSIG_NS, ns);
00192 }
00193 inline void writeBool(std::ostream& ostrm,
00194 Bool arg)
00195 {
00196 BinarySerialization::write(ostrm, BINSIG_BOOL);
00197 arg.writeObject(ostrm);
00198 }
00199 inline void writeClass(std::ostream& ostrm, const CIMClass& cc)
00200 {
00201 BinarySerialization::writeObject(ostrm, BINSIG_CLS, cc);
00202 }
00203 inline void writeInstance(std::ostream& ostrm, const CIMInstance& ci)
00204 {
00205 BinarySerialization::writeObject(ostrm, BINSIG_INST, ci);
00206 }
00207 inline void writeQualType(std::ostream& ostrm, const CIMQualifierType& qt)
00208 {
00209 BinarySerialization::writeObject(ostrm, BINSIG_QUAL_TYPE, qt);
00210 }
00211 inline void writeValue(std::ostream& ostrm, const CIMValue& value)
00212 {
00213 BinarySerialization::writeObject(ostrm, BINSIG_VALUE, value);
00214 }
00215 inline void writeString(std::ostream& ostrm, const String& str)
00216 {
00217 BinarySerialization::write(ostrm, BINSIG_STR);
00218 str.writeObject(ostrm);
00219 }
00220 OW_COMMON_API void readLen(std::istream& istrm, UInt32& len);
00222 template <typename T>
00223 inline void
00224 readArray(std::istream& istr, T& a)
00225 {
00226 a.clear();
00227 UInt32 len;
00228 BinarySerialization::readLen(istr, len);
00229
00230 a.reserve(len);
00231 for (UInt32 i = 0; i < len; i++)
00232 {
00233 typename T::value_type x;
00234 x.readObject(istr);
00235 a.push_back(x);
00236 }
00237
00238 }
00239
00241 template <typename T>
00242 inline void
00243 writeArray(std::ostream& ostrm, const T& a)
00244 {
00245 UInt32 len = static_cast<UInt32>(a.size());
00246 BinarySerialization::writeLen(ostrm, len);
00247 for (UInt32 i = 0; i < len; i++)
00248 {
00249 a.operator[](i).writeObject(ostrm);
00250 }
00251 }
00252 inline void writeStringArray(std::ostream& ostrm,
00253 const StringArray& stra)
00254 {
00255 BinarySerialization::write(ostrm, BINSIG_STRARRAY);
00256 writeArray(ostrm, stra);
00257 }
00258 OW_COMMON_API void writeStringArray(std::ostream& ostrm,
00259 const StringArray* propertyList);
00260
00261
00262 OW_COMMON_API void read(std::istream& istrm, void* dataIn, int dataInLen);
00263 inline void read(std::istream& istrm, String& arg)
00264 {
00265 arg.readObject(istrm);
00266 }
00267 inline void read(std::istream& istrm, Int32& val)
00268 {
00269 BinarySerialization::read(istrm, &val, sizeof(val));
00270 val = ntoh32(val);
00271 }
00272 inline void read(std::istream& istrm, UInt32& val)
00273 {
00274 BinarySerialization::read(istrm, &val, sizeof(val));
00275 val = ntoh32(val);
00276 }
00277 inline void read(std::istream& istrm, UInt16& val)
00278 {
00279 BinarySerialization::read(istrm, &val, sizeof(val));
00280 val = ntoh16(val);
00281 }
00282 inline void read(std::istream& istrm, Int16& val)
00283 {
00284 BinarySerialization::read(istrm, &val, sizeof(val));
00285 val = ntoh16(val);
00286 }
00287 inline void read(std::istream& istrm, UInt8& val)
00288 {
00289 BinarySerialization::read(istrm, &val, sizeof(val));
00290 }
00291 inline void readObject(std::istream& istrm, UInt8 validSig,
00292 CIMBase& obj)
00293 {
00294 obj.readObject(istrm);
00295 }
00296 inline CIMObjectPath readObjectPath(std::istream& istrm)
00297 {
00298 CIMObjectPath op(CIMNULL);
00299 BinarySerialization::readObject(istrm, BINSIG_OP, op);
00300 return op;
00301 }
00302 inline CIMInstance readInstance(std::istream& istrm)
00303 {
00304 CIMInstance ci(CIMNULL);
00305 BinarySerialization::readObject(istrm, BINSIG_INST, ci);
00306 return ci;
00307 }
00308 inline Bool readBool(std::istream& istrm)
00309 {
00310 BinarySerialization::verifySignature(istrm, BINSIG_BOOL);
00311 Bool b;
00312 b.readObject(istrm);
00313 return b;
00314 }
00315 inline CIMNameSpace readNameSpace(std::istream& istrm)
00316 {
00317 CIMNameSpace ns(CIMNULL);
00318 BinarySerialization::readObject(istrm, BINSIG_NS, ns);
00319 return ns;
00320 }
00321 inline CIMClass readClass(std::istream& istrm)
00322 {
00323 CIMClass cc(CIMNULL);
00324 BinarySerialization::readObject(istrm, BINSIG_CLS, cc);
00325 return cc;
00326 }
00327 inline String readString(std::istream& istrm)
00328 {
00329 BinarySerialization::verifySignature(istrm, BINSIG_STR);
00330 String rv;
00331 rv.readObject(istrm);
00332 return rv;
00333 }
00334 inline CIMQualifierType readQualType(std::istream& istrm)
00335 {
00336 CIMQualifierType qt(CIMNULL);
00337 BinarySerialization::readObject(istrm, BINSIG_QUAL_TYPE, qt);
00338 return qt;
00339 }
00340 inline CIMValue readValue(std::istream& istrm)
00341 {
00342 CIMValue value(CIMNULL);
00343 BinarySerialization::readObject(istrm, BINSIG_VALUE, value);
00344 return value;
00345 }
00346 inline StringArray readStringArray(std::istream& istrm)
00347 {
00348 BinarySerialization::verifySignature(istrm, BINSIG_STRARRAY);
00349 StringArray stra;
00350 readArray(istrm, stra);
00351 return stra;
00352 }
00353 OW_COMMON_API void readObjectPathEnum(std::istream& istrm, CIMObjectPathResultHandlerIFC& result);
00354 OW_COMMON_API void readClassEnum(std::istream& istrm, CIMClassResultHandlerIFC& result);
00355 OW_COMMON_API void readInstanceEnum(std::istream& istrm, CIMInstanceResultHandlerIFC& result);
00356 OW_COMMON_API void readQualifierTypeEnum(std::istream& istrm, CIMQualifierTypeResultHandlerIFC& result);
00357 OW_COMMON_API void readStringEnum(std::istream& istrm, StringResultHandlerIFC& result);
00358 }
00359
00360 }
00361
00362 #endif // OW_BinarySerialization_HPP_