Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members

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

Generated on Wed Mar 22 12:23:01 2006 for Artix by  doxygen 1.3.9.1