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
00295
00308
bool setType(Type type,
unsigned long bound = 0);
00309
00315 Type getType()
const {
return type_m;}
00316
00322 const char * getArchiveType()
const {
return archiveTypeName[type_m].c_str(); }
00323
00329 unsigned long getBound()
const {
return ptr_m.bound; };
00330
00336 unsigned long isNull()
const {
return type_m==type_null; }
00337
00348 unsigned long whyIsNull()
const {
return (type_m==type_null)?whyNull_m:
NOT_NULL_VALUE; }
00349
00355
bool noDelta() const;
00356
00361 ~BACIValue();
00362
00363
00370 static Type mapType(
BACIdouble *v=0){ ACE_UNUSED_ARG(v);
return type_double; }
00377 static Type mapType(
BACIfloat *v=0){ ACE_UNUSED_ARG(v);
return type_float; }
00384 static Type mapType(
BACIlong *v=0){ ACE_UNUSED_ARG(v);
return type_long; }
00391
00398 static Type mapType(
char* *v=0){ ACE_UNUSED_ARG(v);
return type_string; }
00405 static Type mapType(ACE_CString *v=0){ ACE_UNUSED_ARG(v);
return type_string; }
00412 static Type mapType(
void* *v=0){ ACE_UNUSED_ARG(v);
return type_pointer; }
00419 static Type mapType(
BACIdoubleSeq *v=0){ ACE_UNUSED_ARG(v);
return type_doubleSeq; }
00426 static Type mapType(
BACIfloatSeq *v=0){ ACE_UNUSED_ARG(v);
return type_floatSeq; }
00433 static Type mapType(
BACIlongSeq *v=0){ ACE_UNUSED_ARG(v);
return type_longSeq; }
00440 static Type mapType(
BACIlongLong *v=0){ ACE_UNUSED_ARG(v);
return type_longLong; }
00447 static Type mapType(
BACIuLongLong *v=0){ ACE_UNUSED_ARG(v);
return type_uLongLong; }
00454 static Type mapType(
BACIstringSeq *v=0){ ACE_UNUSED_ARG(v);
return type_stringSeq; }
00455
00456
00462
const ACE_TCHAR* stringValue() const;
00470 ACE_CString getValue(ACE_CString *v=0) const;
00478
char* getValue(const
char **v=0) const;
00479
00487
char* getValue(
char **v=0) const;
00488
00494
BACIdouble doubleValue() const;
00501
BACIdouble getValue(
BACIdouble *v=0) const;
00512
BACIfloat floatValue() const;
00519
BACIfloat getValue(
BACIfloat *v=0) const;
00525
BACIlong longValue() const;
00532
BACIlong getValue(
BACIlong *v=0) const;
00538
BACIlongLong longLongValue() const;
00545
BACIlongLong getValue(
BACIlongLong *v=0) const;
00551
BACIuLongLong uLongLongValue() const;
00558
BACIuLongLong getValue(
BACIuLongLong *v=0) const;
00564 BACIpattern patternValue()
const {
return uLongLongValue(); }
00565
00571 CORBA::Any enumValue() const;
00572
00579
00580
00587 CORBA::Any getValue(CORBA::Any *v=0) const;
00588
00594
void* pointerValue() const;
00601
void* getValue(
void* *v=0) const;
00607
BACIdoubleSeq doubleSeqValue() const;
00614
BACIdoubleSeq getValue(
BACIdoubleSeq *v=0) const;
00620
BACIfloatSeq floatSeqValue() const;
00627
BACIfloatSeq getValue(
BACIfloatSeq *v=0) const;
00633
BACIlongSeq longSeqValue() const;
00640
BACIlongSeq getValue(
BACIlongSeq *v=0) const;
00646
BACIstringSeq stringSeqValue() const;
00653
BACIstringSeq getValue(
BACIstringSeq *v=0) const;
00654
00662
bool doubleValue(const
BACIdouble &value);
00670
bool setValue(const
BACIdouble &value);
00678
bool floatValue(const
BACIfloat &value);
00686
bool setValue(const
BACIfloat &value);
00694
bool longValue(const
BACIlong &value);
00702
bool setValue(const
BACIlong &value);
00710
bool longLongValue(const
BACIlongLong &value);
00718
bool setValue(const
BACIlongLong &value);
00726
bool uLongLongValue(const
BACIuLongLong &value);
00734
bool setValue(const
BACIuLongLong &value);
00742 bool patternValue(const
BACIpattern &value){
return setValue(value); }
00743
00751
00752
bool enumValue(
const BACIpattern &value,
const CORBA::Any &anyVal);
00753
00761
00762
00770
00771
00779
bool stringValue(
const ACE_CString &value);
00787
bool setValue(
const ACE_CString &value);
00795
bool stringValue (
const char * value);
00803
bool setValue (
const char * value);
00811
bool pointerValue (
void * value);
00819
bool doubleSeqValue(
const BACIdoubleSeq &value);
00827
bool setValue(
const BACIdoubleSeq &value);
00835
bool floatSeqValue(
const BACIfloatSeq &value);
00843
bool setValue(
const BACIfloatSeq &value);
00851
bool longSeqValue(
const BACIlongSeq &value);
00859
bool setValue(
const BACIlongSeq &value);
00867
bool stringSeqValue(
const BACIstringSeq &value);
00875
bool setValue(
const BACIstringSeq &value);
00876
00877
00887
bool toString(ACE_CString &value,
bool specifyType =
false)
const;
00888
00898
bool fromString(
const ACE_CString value,
bool specifyType =
false);
00899
00900
00907
void
00908 getAny(CORBA::Any &any)
const;
00909
00910
protected:
00911
00915 Type type_m;
00916
00917
union
00918
{
00925 double inlineData_m[2];
00926
00933
struct
00934
{
00935 unsigned long bound;
00936 void *pointer;
00937 } ptr_m;
00938
00942 unsigned long whyNull_m;
00943 };
00944
00950 CORBA::Any any_m;
00951
00955 bool isEnum_m;
00956
00957 };
00958
00959
00960
00961
#include "baciValue.i"
00962
00963 };
00964
00965
00966
00967 std::istream&
operator>>(std::istream &is, ACE_CString &data);
00968
00969
#endif