Go to the documentation of this file.00001 #ifndef baciValue_H
00002 #define baciValue_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
00030
00031
00037 #ifndef __cplusplus
00038 #error This is a C++ include file and cannot be used from plain C
00039 #endif
00040
00041 #include <acsutil.h>
00042 #include <baciExport.h>
00043 #include <baciTypes.h>
00044 #include <ace/SString.h>
00045
00046 namespace baci {
00047
00051
00052 #define NOT_NULL_VALUE 0
00053
00054 #define VALUE_NULL 1
00055
00056 #define VALUE_UNINITIALIZED 2
00057
00058 #define VALUE_NONEXISTENT 3
00059
00068 class baci_EXPORT BACIValue
00069 {
00070
00071 public:
00072
00078 enum Type
00079 {
00081 type_null=0,
00084 type_pointer=1,
00086 type_string=2,
00088 type_double=3,
00090 type_long=4,
00092 type_pattern=9,
00094 type_doubleSeq=6,
00096 type_longSeq=7,
00098 type_longLong=8,
00100 type_uLongLong=9,
00102 type_stringSeq=10,
00104 type_float=11,
00106 type_floatSeq=12
00107 };
00108
00113 typedef unsigned char octet;
00114
00123 static const ACE_CString typeName[];
00124
00134 static const ACE_CString archiveTypeName[];
00135
00140 static const BACIValue NullValue;
00141
00142
00147 BACIValue();
00148
00157 BACIValue(const Type type, const unsigned long bound);
00158
00164 BACIValue(const BACIValue &value);
00165
00171 BACIValue(const BACIdouble &value);
00177 BACIValue(const BACIfloat &value);
00183 BACIValue(const BACIlong &value);
00189
00195 BACIValue(const BACIlongLong &value);
00201 BACIValue(const BACIuLongLong &value);
00207 BACIValue(const ACE_CString &value);
00213 BACIValue(const char* value);
00219 BACIValue(const void* &value);
00225 BACIValue(void * value);
00231 BACIValue(const BACIdoubleSeq &value);
00237 BACIValue(const BACIfloatSeq &value);
00243 BACIValue(const BACIlongSeq &value);
00249 BACIValue(const BACIstringSeq &value);
00250
00256 BACIValue(const BACIpattern &value, const CORBA::Any& any);
00257
00262 void reset();
00263
00264
00269 BACIValue& operator=(const BACIValue &value);
00274 bool operator==(const BACIValue &value) const;
00279 bool operator<(const BACIValue &value) const;
00284 bool operator<=(const BACIValue &value) const;
00285
00293 bool lessThanDelta(const BACIValue &value, const BACIValue &delta) const;
00294
00302 bool lessThanPercentDelta(const BACIValue &value, const BACIValue &delta) const;
00303
00304
00317 bool setType(Type type, unsigned long bound = 0);
00318
00324 Type getType() const { return type_m;}
00325
00331 const char * getArchiveType() const { return archiveTypeName[type_m].c_str(); }
00332
00338 unsigned long getBound() const { return ptr_m.bound; };
00339
00345 unsigned long isNull() const { return type_m==type_null; }
00346
00357 unsigned long whyIsNull() const { return (type_m==type_null)?whyNull_m:NOT_NULL_VALUE; }
00358
00364 bool noDelta() const;
00365
00370 ~BACIValue();
00371
00372
00379 static Type mapType(BACIdouble *v=0){ ACE_UNUSED_ARG(v); return type_double; }
00386 static Type mapType(BACIfloat *v=0){ ACE_UNUSED_ARG(v); return type_float; }
00393 static Type mapType(BACIlong *v=0){ ACE_UNUSED_ARG(v); return type_long; }
00400
00407 static Type mapType(char* *v=0){ ACE_UNUSED_ARG(v); return type_string; }
00414 static Type mapType(ACE_CString *v=0){ ACE_UNUSED_ARG(v); return type_string; }
00421 static Type mapType(void* *v=0){ ACE_UNUSED_ARG(v); return type_pointer; }
00428 static Type mapType(BACIdoubleSeq *v=0){ ACE_UNUSED_ARG(v); return type_doubleSeq; }
00435 static Type mapType(BACIfloatSeq *v=0){ ACE_UNUSED_ARG(v); return type_floatSeq; }
00442 static Type mapType(BACIlongSeq *v=0){ ACE_UNUSED_ARG(v); return type_longSeq; }
00449 static Type mapType(BACIlongLong *v=0){ ACE_UNUSED_ARG(v); return type_longLong; }
00456 static Type mapType(BACIuLongLong *v=0){ ACE_UNUSED_ARG(v); return type_uLongLong; }
00463 static Type mapType(BACIstringSeq *v=0){ ACE_UNUSED_ARG(v); return type_stringSeq; }
00464
00465
00471 const ACE_TCHAR* stringValue() const;
00479 ACE_CString getValue(ACE_CString *v=0) const;
00487 char* getValue(const char **v=0) const;
00488
00496 char* getValue(char **v=0) const;
00497
00503 BACIdouble doubleValue() const;
00510 BACIdouble getValue(BACIdouble *v=0) const;
00521 BACIfloat floatValue() const;
00528 BACIfloat getValue(BACIfloat *v=0) const;
00534 BACIlong longValue() const;
00541 BACIlong getValue(BACIlong *v=0) const;
00547 BACIlongLong longLongValue() const;
00554 BACIlongLong getValue(BACIlongLong *v=0) const;
00560 BACIuLongLong uLongLongValue() const;
00567 BACIuLongLong getValue(BACIuLongLong *v=0) const;
00573 BACIpattern patternValue() const { return uLongLongValue(); }
00574
00580 CORBA::Any enumValue() const;
00581
00588
00589
00596 CORBA::Any getValue(CORBA::Any *v=0) const;
00597
00603 void* pointerValue() const;
00610 void* getValue(void* *v=0) const;
00616 BACIdoubleSeq doubleSeqValue() const;
00623 BACIdoubleSeq getValue(BACIdoubleSeq *v=0) const;
00629 BACIfloatSeq floatSeqValue() const;
00636 BACIfloatSeq getValue(BACIfloatSeq *v=0) const;
00642 BACIlongSeq longSeqValue() const;
00649 BACIlongSeq getValue(BACIlongSeq *v=0) const;
00655 BACIstringSeq stringSeqValue() const;
00662 BACIstringSeq getValue(BACIstringSeq *v=0) const;
00663
00671 bool doubleValue(const BACIdouble &value);
00679 bool setValue(const BACIdouble &value);
00687 bool floatValue(const BACIfloat &value);
00695 bool setValue(const BACIfloat &value);
00703 bool longValue(const BACIlong &value);
00711 bool setValue(const BACIlong &value);
00719 bool longLongValue(const BACIlongLong &value);
00727 bool setValue(const BACIlongLong &value);
00735 bool uLongLongValue(const BACIuLongLong &value);
00743 bool setValue(const BACIuLongLong &value);
00751 bool patternValue(const BACIpattern &value){ return setValue(value); }
00752
00760
00761 bool enumValue(const BACIpattern &value, const CORBA::Any &anyVal);
00762
00770
00771
00779
00780
00788 bool stringValue(const ACE_CString &value);
00796 bool setValue(const ACE_CString &value);
00804 bool stringValue (const char * value);
00812 bool setValue (const char * value);
00820 bool pointerValue (void * value);
00828 bool doubleSeqValue(const BACIdoubleSeq &value);
00836 bool setValue(const BACIdoubleSeq &value);
00844 bool floatSeqValue(const BACIfloatSeq &value);
00852 bool setValue(const BACIfloatSeq &value);
00860 bool longSeqValue(const BACIlongSeq &value);
00868 bool setValue(const BACIlongSeq &value);
00876 bool stringSeqValue(const BACIstringSeq &value);
00884 bool setValue(const BACIstringSeq &value);
00885
00886
00896 bool toString(ACE_CString &value, bool specifyType = false) const;
00897
00907 bool fromString(const ACE_CString value, bool specifyType = false);
00908
00909
00916 void
00917 getAny(CORBA::Any &any) const;
00918
00919 protected:
00920
00924 Type type_m;
00925
00926 union
00927 {
00934 double inlineData_m[2];
00935
00942 struct
00943 {
00944 unsigned long bound;
00945 void *pointer;
00946 } ptr_m;
00947
00951 unsigned long whyNull_m;
00952 };
00953
00959 CORBA::Any any_m;
00960
00964 bool isEnum_m;
00965
00966 };
00967
00968
00969
00970 #include "baciValue.i"
00971
00972 };
00973
00974
00975
00976 std::istream& operator>>(std::istream &is, ACE_CString &data);
00977
00978 #endif