• 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.112 2012/10/09 14:22:58 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,
00108         type_uLong=13,
00110         type_uLongSeq=14,
00112         type_boolean=15,
00114         type_booleanSeq=16
00115     };
00116 
00121     typedef unsigned char octet;
00122 
00132     static const ACE_CString typeName[];
00133 
00144     static const ACE_CString archiveTypeName[];
00145 
00150     static const BACIValue NullValue;
00151 
00152     // --Constructors--------------------------------------------------------
00157     BACIValue();
00158 
00167     BACIValue(const Type type, const unsigned long bound);
00168 
00174     BACIValue(const BACIValue &value);
00175 
00181     BACIValue(const BACIdouble &value);
00187     BACIValue(const BACIfloat &value);
00193     BACIValue(const BACIlong &value);
00199     BACIValue(const BACIuLong &value);
00205 //TOBE deleted    BACIValue(const BACIpattern &value);
00211     BACIValue(const BACIlongLong &value);
00217     BACIValue(const BACIuLongLong &value);
00223     BACIValue(const ACE_CString &value);
00229     BACIValue(const char* value);
00235     BACIValue(const BACIboolean &value);
00241     BACIValue(const void* &value);
00247     BACIValue(void * value);
00253     BACIValue(const BACIdoubleSeq &value);
00259     BACIValue(const BACIfloatSeq &value);
00265     BACIValue(const BACIlongSeq &value);
00271     BACIValue(const BACIuLongSeq &value);
00277     BACIValue(const BACIstringSeq &value);
00278 
00284     BACIValue(const BACIpattern &value, const CORBA::Any& any);
00290     BACIValue(const BACIbooleanSeq &value);
00291 
00296     void reset();
00297 
00298     // --Operators-----------------------------------------------------------
00303     BACIValue& operator=(const BACIValue &value);
00308     bool operator==(const BACIValue &value) const;
00313     bool operator<(const BACIValue &value) const;
00318     bool operator<=(const BACIValue &value) const;
00319 
00327     bool lessThanDelta(const BACIValue &value, const BACIValue &delta) const;
00328 
00336     bool lessThanPercentDelta(const BACIValue &value, const BACIValue &delta) const;
00337 
00338     // --Methods-------------------------------------------------------------
00351     bool setType(Type type, unsigned long bound = 0);
00352 
00358     Type getType() const { return type_m;}
00359 
00365     const char * getArchiveType() const { return archiveTypeName[type_m].c_str(); }
00366 
00372     unsigned long getBound() const { return ptr_m.bound; };
00373 
00379     unsigned long isNull() const { return type_m==type_null; }
00380 
00391     unsigned long whyIsNull() const { return (type_m==type_null)?whyNull_m:NOT_NULL_VALUE; }
00392 
00398     bool noDelta() const;
00399 
00404     ~BACIValue();
00405 
00406     // ----------------------------------------------------------------------
00413     static Type mapType(BACIdouble *v=0){  ACE_UNUSED_ARG(v); return type_double; }
00420     static Type mapType(BACIfloat *v=0){  ACE_UNUSED_ARG(v); return type_float; }
00427     static Type mapType(BACIlong *v=0){  ACE_UNUSED_ARG(v); return type_long; }
00434     static Type mapType(BACIuLong *v=0){  ACE_UNUSED_ARG(v); return type_uLong; }
00441 //TOBE deleted    static Type mapType(BACIpattern *v=0){  ACE_UNUSED_ARG(v); return type_pattern; }
00448     static Type mapType(char* *v=0){  ACE_UNUSED_ARG(v); return type_string; }
00455     static Type mapType(ACE_CString *v=0){  ACE_UNUSED_ARG(v); return type_string; }
00462     static Type mapType(BACIboolean *v=0){  ACE_UNUSED_ARG(v); return type_boolean; }
00469     static Type mapType(void* *v=0){  ACE_UNUSED_ARG(v); return type_pointer; }
00476     static Type mapType(BACIdoubleSeq *v=0){  ACE_UNUSED_ARG(v); return type_doubleSeq; }
00483     static Type mapType(BACIfloatSeq *v=0){  ACE_UNUSED_ARG(v); return type_floatSeq; }
00490     static Type mapType(BACIlongSeq *v=0){  ACE_UNUSED_ARG(v); return type_longSeq; }
00497     static Type mapType(BACIuLongSeq *v=0){  ACE_UNUSED_ARG(v); return type_uLongSeq; }
00504     static Type mapType(BACIlongLong *v=0){  ACE_UNUSED_ARG(v); return type_longLong; }
00511     static Type mapType(BACIuLongLong *v=0){  ACE_UNUSED_ARG(v); return type_uLongLong; }
00518     static Type mapType(BACIstringSeq *v=0){  ACE_UNUSED_ARG(v); return type_stringSeq; }
00525     static Type mapType(BACIbooleanSeq *v=0){  ACE_UNUSED_ARG(v); return type_booleanSeq; }
00526     // ------------------------------------------------------------------
00527     //accessors
00533     const ACE_TCHAR* stringValue() const;
00541     ACE_CString getValue(ACE_CString *v=0) const;
00549     char* getValue(const char **v=0) const;
00550 
00558     char* getValue(char **v=0) const;
00559 
00565     BACIdouble doubleValue() const;
00572     BACIdouble getValue(BACIdouble *v=0) const;
00583     BACIfloat floatValue() const;
00590     BACIfloat getValue(BACIfloat *v=0) const;
00596     BACIlong longValue() const;
00603     BACIlong getValue(BACIlong *v=0) const;
00609     BACIuLong uLongValue() const;
00616     BACIuLong getValue(BACIuLong *v=0) const;
00622     BACIlongLong longLongValue() const;
00629     BACIlongLong getValue(BACIlongLong *v=0) const;
00635     BACIuLongLong uLongLongValue() const;
00642     BACIuLongLong getValue(BACIuLongLong *v=0) const;
00648     BACIpattern patternValue() const { return uLongLongValue(); }
00654     BACIboolean booleanValue() const;
00661     BACIboolean getValue(BACIboolean *v=0) const;
00662 
00668     CORBA::Any enumValue() const;
00669 
00676 //TOBE deleted    BACIpattern getValue(BACIpattern *v=0) const;
00677 
00684     CORBA::Any getValue(CORBA::Any *v=0) const;
00685 
00691     void* pointerValue() const;
00698     void* getValue(void* *v=0) const;
00704     BACIdoubleSeq doubleSeqValue() const;
00711     BACIdoubleSeq getValue(BACIdoubleSeq *v=0) const;
00717     BACIfloatSeq floatSeqValue() const;
00724     BACIfloatSeq getValue(BACIfloatSeq *v=0) const;
00730     BACIlongSeq longSeqValue() const;
00737     BACIlongSeq getValue(BACIlongSeq *v=0) const;
00743     BACIuLongSeq uLongSeqValue() const;
00750     BACIuLongSeq getValue(BACIuLongSeq *v=0) const;
00756     BACIstringSeq stringSeqValue() const;
00763     BACIstringSeq getValue(BACIstringSeq *v=0) const;
00769     BACIbooleanSeq booleanSeqValue() const;
00776     BACIbooleanSeq getValue(BACIbooleanSeq *v=0) const;
00777     // ------------------------------------------------------------------
00785     bool doubleValue(const BACIdouble &value);
00793     bool setValue(const BACIdouble &value);
00801     bool floatValue(const BACIfloat &value);
00809     bool setValue(const BACIfloat &value);
00817     bool longValue(const BACIlong &value);
00825     bool setValue(const BACIlong &value);
00833     bool uLongValue(const BACIuLong &value);
00841     bool setValue(const BACIuLong &value);
00849     bool longLongValue(const BACIlongLong &value);
00857     bool setValue(const BACIlongLong &value);
00865     bool uLongLongValue(const BACIuLongLong &value);
00873     bool setValue(const BACIuLongLong &value);
00881     bool patternValue(const BACIpattern &value){ return setValue(value); }
00882 
00890 //??    bool enumValue(const int &value, const CORBA::Any &anyVal);
00891     bool enumValue(const BACIpattern &value, const CORBA::Any &anyVal);
00892 
00900 //TOBE deleted    bool setValue(const BACIpattern &value);
00901 
00909 //TOBE deleted    bool setValue(const BACIpattern &value, const CORBA::Any &anyVal);
00910 
00918     bool stringValue(const ACE_CString &value);
00926     bool setValue(const ACE_CString &value);
00934     bool stringValue (const char * value);
00942     bool setValue (const char * value);
00950     bool booleanValue(const BACIboolean &value);
00958     bool setValue(const BACIboolean &value);
00966     bool pointerValue (void * value);
00974     bool doubleSeqValue(const BACIdoubleSeq &value);
00982     bool setValue(const BACIdoubleSeq &value);
00990     bool floatSeqValue(const BACIfloatSeq &value);
00998     bool setValue(const BACIfloatSeq &value);
01006     bool longSeqValue(const BACIlongSeq &value);
01014     bool setValue(const BACIlongSeq &value);
01022     bool uLongSeqValue(const BACIuLongSeq &value);
01030     bool setValue(const BACIuLongSeq &value);
01038     bool stringSeqValue(const BACIstringSeq &value);
01046     bool setValue(const BACIstringSeq &value);
01054     bool booleanSeqValue(const BACIbooleanSeq &value);
01062     bool setValue(const BACIbooleanSeq &value);
01063     // ------------------------------------------------------------------
01064     //Conversion helpers
01074     bool toString(ACE_CString &value, bool specifyType = false) const;
01075 
01085     bool fromString(const ACE_CString value, bool specifyType = false);
01086     // ------------------------------------------------------------------
01087 
01094     void
01095     getAny(CORBA::Any &any) const;
01096 
01097   protected:
01098 
01102     Type type_m;
01103 
01104     union
01105     {
01112         double inlineData_m[2];
01113 
01120         struct
01121         {
01122             unsigned long bound;
01123             void *pointer;
01124         } ptr_m;
01125 
01129         unsigned long whyNull_m;
01130     };
01131 
01137     CORBA::Any any_m;
01138 
01142     bool isEnum_m;
01143 
01144 };
01145 
01146 
01147 
01148 #include "baciValue.i"
01149 
01150  }; 
01151 
01152 // ------------------[ Stream extraction ]-----------------------
01153 
01154 std::istream& operator>>(std::istream &is, ACE_CString &data);
01155 
01156 #endif 

Generated on Mon May 4 2015 08:27:42 for ACS-2015.4 C++ API by  doxygen 1.7.0