• Classes
  • Modules
  • Namespaces
  • Files
  • Related Pages
  • File List
  • File Members

baciValue.h

Go to the documentation of this file.
00001 #ifndef baciValue_H
00002 #define baciValue_H
00003 /*******************************************************************
00004  * ALMA - Atacama Large Millimiter Array
00005  * (c) European Southern Observatory, 2004
00006  *
00007  *This library is free software; you can redistribute it and/or
00008  *modify it under the terms of the GNU Lesser General Public
00009  *License as published by the Free Software Foundation; either
00010  *version 2.1 of the License, or (at your option) any later version.
00011  *
00012  *This library is distributed in the hope that it will be useful,
00013  *but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  *Lesser General Public License for more details.
00016  *
00017  *You should have received a copy of the GNU Lesser General Public
00018  *License along with this library; if not, write to the Free Software
00019  *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00020  *
00021  * "@(#) $Id: baciValue.h,v 1.110 2008/08/21 15:30:52 bjeram Exp $"
00022  *
00023  * who       when        what
00024  * --------  ----------  ----------------------------------------------
00025  * bjeram    2003/08/08  changed octet inlineData_m[8] to double inlineData_m[2] duo to having problem on Sun with alignment
00026  * bjeram    2003/02/11  added MUTATOR(string, ACE_CString)
00027  * bjeram    2002/12/19  added accesor mutator template functions (temporary!!!)
00028  * msekoran  2001/07/26  fixed string type
00029  * msekoran  2001/03/02  created
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, //5,
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     // --Constructors--------------------------------------------------------
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 //TOBE deleted    BACIValue(const BACIpattern &value);
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     // --Operators-----------------------------------------------------------
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     // --Methods-------------------------------------------------------------
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 //TOBE deleted    static Type mapType(BACIpattern *v=0){  ACE_UNUSED_ARG(v); return type_pattern; }
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     //accessors
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 //TOBE deleted    BACIpattern getValue(BACIpattern *v=0) const;
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 //??    bool enumValue(const int &value, const CORBA::Any &anyVal);
00752     bool enumValue(const BACIpattern &value, const CORBA::Any &anyVal);
00753 
00761 //TOBE deleted    bool setValue(const BACIpattern &value);
00762 
00770 //TOBE deleted    bool setValue(const BACIpattern &value, const CORBA::Any &anyVal);
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     //Conversion helpers
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 // ------------------[ Stream extraction ]-----------------------
00966 
00967 std::istream& operator>>(std::istream &is, ACE_CString &data);
00968 
00969 #endif 

Generated on Thu Jul 8 2010 19:47:47 for ACS-9.0 C++ API by  doxygen 1.7.0