summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Notify/Property_T.cpp
blob: 051345844c1c89fb2d9604bb489e62844c9171a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// $Id$

#ifndef TAO_NS_PROPERTY_T_CPP
#define TAO_NS_PROPERTY_T_CPP

#include "Property_T.h"

#if ! defined (__ACE_INLINE__)
#include "Property_T.inl"
#endif /* __ACE_INLINE__ */

ACE_RCSID(Notify, TAO_NS_Property_T, "$id$")

#include "PropertySeq.h"

/*******************************************************************************/

template <class TYPE>
TAO_NS_PropertyBase_T<TYPE>::TAO_NS_PropertyBase_T (const ACE_CString& name)
  :name_ (name), valid_(0)
{
}

template <class TYPE>
TAO_NS_PropertyBase_T<TYPE>::TAO_NS_PropertyBase_T (const ACE_CString& name, const TYPE& initial)
  :name_ (name), value_ (initial), valid_ (1)
{
}

template <class TYPE>
TAO_NS_PropertyBase_T<TYPE>::TAO_NS_PropertyBase_T (const TAO_NS_PropertyBase_T &rhs)
{
  this->name_ = rhs.name_;
  this->value_ = rhs.value_;
  this->valid_ = rhs.valid_;
}

template <class TYPE>
TAO_NS_PropertyBase_T<TYPE>::~TAO_NS_PropertyBase_T ()
{
}

template <class TYPE> void
TAO_NS_PropertyBase_T<TYPE>::get (CosNotification::PropertySeq& prop_seq)
{
  /// Make space
  prop_seq.length (prop_seq.length () + 1);

  prop_seq[prop_seq.length () - 1].value <<= this->value_;
}

/*******************************************************************************/

template <class TYPE>
TAO_NS_Property_T<TYPE>::TAO_NS_Property_T (const ACE_CString& name)
  :TAO_NS_PropertyBase_T <TYPE> (name)
{
}

template <class TYPE>
TAO_NS_Property_T<TYPE>::TAO_NS_Property_T (const ACE_CString& name, const TYPE& initial)
  :TAO_NS_PropertyBase_T <TYPE> (name, initial)
{
}

template <class TYPE> int
TAO_NS_Property_T<TYPE>::set (const TAO_NS_PropertySeq& property_seq)
{
  CosNotification::PropertyValue value;

  if (property_seq.find (this->name_, value) == -1)
    {
      this->valid_ = 0;
      return -1;
    }

  value >>= this->value_;

  this->valid_ = 1;

  return 0;
}

/*******************************************************************************/

template <class TYPE>
TAO_NS_StructProperty_T<TYPE>::TAO_NS_StructProperty_T (const ACE_CString& name)
  :name_ (name), valid_(0)
{
}

template <class TYPE>
TAO_NS_StructProperty_T<TYPE>::TAO_NS_StructProperty_T (const ACE_CString& name, const TYPE& initial)
  :name_ (name), value_ (initial), valid_ (1)
{
}

template <class TYPE> int
TAO_NS_StructProperty_T<TYPE>::set (const TAO_NS_PropertySeq& property_seq)
{
  CosNotification::PropertyValue value;

  if (property_seq.find (this->name_, value) == -1)
    {
      this->valid_ = 0;
      return -1;
    }

  TYPE* extract_type;
  value >>= extract_type;

  this->value_ = *extract_type; // copy

  this->valid_ = 1;

  return 0;
}

#endif /* TAO_NS_PROPERTY_T_CPP */