[omniORB] How to use attributes

Duncan Grisby dgrisby@uk.research.att.com
Wed, 28 Apr 1999 09:23:40 +0100

On Wednesday 28 April, "Cristi" wrote:

> Can you write a short sample code of how you implement the methods to set
> the value or retrieve the value of an attribute of an object?
> for example:
> interface Obj1 {
>     attribute string name;
> };
> How do you implement Obj1_i::name() and Obj1_i::name(const char* _value) ?

These operations can do anything you like. Attributes are just
syntactic sugar for:

interface Obj1 {
  string get_name();
  void   set_name(in string s);

In the trivial case where there is a string member variable in the
object implementation, you can just define the operations to set and
return the member string. You must be careful to get your memory
management right, and call CORBA::string_dup() at the correct times.



 -- Duncan Grisby  \  Research Engineer  --
  -- AT&T Laboratories Cambridge          --
   -- http://www.uk.research.att.com/~dpg1 --