it_bus/named_attributes.h

00001 #ifndef _IT_BUS_NAMED_ATTRIBUTES_H_
00002 #define _IT_BUS_NAMED_ATTRIBUTES_H_
00003 
00004 // @Copyright 2004 IONA Technologies, Plc. All Rights Reserved.
00005 //
00006 
00007 #include <it_bus/api_defines.h>
00008 #include <it_bus/types.h>
00009 #include <it_bus/string_map.h>
00010 
00011 #ifndef IT_MINIMISE_INCLUDES
00012 #include <it_bus/binary_buffer.h>
00013 #endif
00014 
00015 namespace IT_Bus
00016 {
00017     class IT_BUS_API WrongTypeException :
00018         public Exception
00019     {
00020       public:
00021         WrongTypeException(
00022             String message
00023         );      
00024 
00025         virtual ~WrongTypeException();        
00026 
00030         virtual Exception*
00031         clone() const;
00032     
00036         virtual void
00037         rethrow() const;
00038     };
00039 
00040     class IT_BUS_API NoSuchAttributeException :
00041         public Exception
00042     {
00043       public:
00044         NoSuchAttributeException(
00045             String message
00046         );        
00047 
00048         virtual ~NoSuchAttributeException();        
00049 
00053         virtual Exception*
00054         clone() const;
00055     
00059         virtual void
00060         rethrow() const;
00061     };
00062 
00063     class IT_BUS_API NamedAttributes
00064     {
00065       public:
00066         typedef IT_Vector<String> StringList;
00067         
00068         NamedAttributes() {}
00069         
00070         virtual ~NamedAttributes();
00071         
00072         virtual Boolean
00073         get_boolean(
00074             const String& name
00075         ) const throw((WrongTypeException, NoSuchAttributeException));
00076         
00077         virtual void
00078         set_boolean(
00079             const String& name,
00080             Boolean data
00081         ) throw((WrongTypeException, NoSuchAttributeException));
00082         
00083         virtual Byte
00084         get_byte(
00085             const String& name
00086         ) const throw((WrongTypeException, NoSuchAttributeException));
00087         
00088         virtual void
00089         set_byte(
00090             const String& name,
00091             Byte data
00092         ) throw((WrongTypeException, NoSuchAttributeException));
00093         
00094         virtual Short
00095         get_short(
00096             const String& name
00097         ) const throw((WrongTypeException, NoSuchAttributeException));
00098         
00099         virtual void
00100         set_short(
00101             const String& name,
00102             Short data
00103         ) throw((WrongTypeException, NoSuchAttributeException));
00104         
00105         virtual Int
00106         get_int(
00107             const String& name
00108         ) const throw((WrongTypeException, NoSuchAttributeException));
00109         
00110         virtual void
00111         set_int(
00112             const String& name,
00113             Int data
00114         ) throw((WrongTypeException, NoSuchAttributeException));
00115         
00116         virtual Long
00117         get_long(
00118             const String& name
00119         ) const throw((WrongTypeException, NoSuchAttributeException));
00120         
00121         virtual void
00122         set_long(
00123             const String& name,
00124             Long data
00125         ) throw((WrongTypeException, NoSuchAttributeException));
00126         
00127         virtual UByte
00128         get_ubyte(
00129             const String& name
00130         ) const throw((WrongTypeException, NoSuchAttributeException));
00131         
00132         virtual void
00133         set_ubyte(
00134             const String& name,
00135             UByte data
00136         ) throw((WrongTypeException, NoSuchAttributeException));
00137         
00138         virtual UShort
00139         get_ushort(
00140             const String& name
00141         ) const throw((WrongTypeException, NoSuchAttributeException));
00142         
00143         virtual void
00144         set_ushort(
00145             const String& name,
00146             UShort data
00147         ) throw((WrongTypeException, NoSuchAttributeException));
00148         
00149         virtual UInt
00150         get_uint(
00151             const String& name
00152         ) const throw((WrongTypeException, NoSuchAttributeException));
00153         
00154         virtual void
00155         set_uint(
00156             const String& name,
00157             UInt data
00158         ) throw((WrongTypeException, NoSuchAttributeException));
00159         
00160         virtual ULong
00161         get_ulong(
00162             const String& name
00163         ) const throw((WrongTypeException, NoSuchAttributeException));
00164         
00165         virtual void
00166         set_ulong(
00167             const String& name,
00168             ULong data
00169         ) throw((WrongTypeException, NoSuchAttributeException));
00170         
00171         virtual Float
00172         get_float(
00173             const String& name
00174         ) const throw((WrongTypeException, NoSuchAttributeException));
00175         
00176         virtual void
00177         set_float(
00178             const String& name,
00179             Float data
00180         ) throw((WrongTypeException, NoSuchAttributeException));
00181         
00182         virtual Double
00183         get_double(
00184             const String& name
00185         ) const throw((WrongTypeException, NoSuchAttributeException));
00186         
00187         virtual void
00188         set_double(
00189             const String& name,
00190             Double data
00191         ) throw((WrongTypeException, NoSuchAttributeException));
00192         
00193         virtual const String&
00194         get_string(
00195             const String& name
00196         ) const throw((WrongTypeException, NoSuchAttributeException));
00197         
00198         virtual void
00199         set_string(
00200             const String& name,
00201             const String& data
00202         ) throw((WrongTypeException, NoSuchAttributeException));
00203         
00204         virtual const StringList&
00205         read_list(
00206             const String& name
00207         ) const throw((WrongTypeException, NoSuchAttributeException));
00208         
00209         virtual StringList&
00210         write_list(
00211             const String& name
00212         ) throw((WrongTypeException, NoSuchAttributeException));
00213         
00214         virtual const StringList&
00215         get_names();
00216         
00217         virtual void
00218         clear_name_values();
00219 
00220         void bind_boolean(const String& name, Boolean* value);
00221         void bind_byte(const String& name, Byte* value);
00222         void bind_int(const String& name, Int* value);
00223         void bind_short(const String& name, Short* value);
00224         void bind_long(const String& name, Long* value);
00225         void bind_ubyte(const String& name, UByte* value);
00226         void bind_ushort(const String& name, UShort* value);
00227         void bind_uint(const String& name, UInt* value);
00228         void bind_ulong(const String& name, ULong* value);
00229         void bind_float(const String& name, Float* value);
00230         void bind_double(const String& name, Double* value);
00231         void bind_string(const String& name, String* value);
00232         void bind_string_list(const String& name, StringList* value);
00233         
00234       private:
00235         
00236         struct Value
00237         {
00238             enum Type
00239             {
00240                 TYPE_BOOLEAN,
00241                 TYPE_BYTE,
00242                 TYPE_SHORT,
00243                 TYPE_INT,
00244                 TYPE_LONG,
00245                 TYPE_UBYTE,
00246                 TYPE_USHORT,
00247                 TYPE_UINT,
00248                 TYPE_ULONG,
00249                 TYPE_FLOAT,
00250                 TYPE_DOUBLE,
00251                 TYPE_STRING,
00252                 TYPE_STRING_LIST
00253             };
00254             
00255             union Data
00256             {
00257                 Boolean*    data_boolean;
00258                 Byte*       data_byte;
00259                 Short*      data_short;
00260                 Int*        data_int;
00261                 Long*       data_long;
00262                 UByte*      data_ubyte;
00263                 UShort*     data_ushort;
00264                 UInt*       data_uint;
00265                 ULong*      data_ulong;
00266                 Float*      data_float;
00267                 Double*     data_double;
00268                 String*     data_string;
00269                 StringList* data_string_list;
00270             };
00271 
00272             Type m_type;
00273             Data m_data;
00274         };
00275         
00276         typedef StringMap<Value> NameValueMap;
00277         
00278         const Value&
00279         find(
00280             const String& name,
00281             Value::Type type
00282         ) const throw((WrongTypeException, NoSuchAttributeException));
00283         
00284         Value&
00285         find(
00286             const String& name,
00287             Value::Type type
00288         ) throw((WrongTypeException, NoSuchAttributeException));
00289 
00290         NameValueMap m_nv_map;        
00291         StringList m_names;        
00292     };
00293 }
00294 
00295 #endif  

Generated on Tue Mar 20 15:27:41 2007 for Artix by  doxygen 1.5.1-p1