summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Property_Exporter.h
blob: 3db368a5bb50ef3d00c25b6627096f62949de60f (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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/* -*- C++ -*- */

// ========================================================================
// $Id$
// 
// = LIBRARY
//    TAO/orbsvcs/orbsvcs
//
// = FILENAME
//    Property_Exporter.h
//
// = DESCRIPTION
//    Allows a service to export properties to both a Property Set and
//    a Trading Service simulatenously.
//    
// = AUTHORS
//    Seth Widoff <sbw1@cs.wustl.edu>
//
// ========================================================================

#if ! defined (TAO_PROPERTY_EXPORTER_H)
#define TAO_PROPERTY_EXPORTER_H

#include "orbsvcs/CosTradingC.h"
#include "orbsvcs/CosPropertyServiceC.h"
#include "orbsvcs/Trader/Trader_Utils.h"

class TAO_Property_Exporter;

class TAO_Exportable
// = DESCRIPTION
//   Interface that allows property containers to export their
//   properties to a TAO_Property_Exporter instance.
{
public:

  virtual void
    export_properties (TAO_Property_Exporter& prop_exporter) {}
  // Insert exportable properties into the proper_exporter.

  virtual int define_properties
    (CosTradingRepos::ServiceTypeRepository::PropStructSeq& prop_seq,
     CORBA::ULong offset = 0) const = 0;
  // Append property definitions to the service type defintition
  // sequence. The <offset> is the point at which the method can begin 
  // placing the PropStructures. define_properties returns the number
  // of properties inserted from the offset.
};


class TAO_Property_Exporter 
// = TITLE
//   Publish public properties of a servant to a
//   CosPropertyService::PropSet instance and a Trading Service
//   offer.
//
//   Use this class in the following way:
//   1. Instantiate.
//   2. for (int i = 0; i < num_properties; i++)  add_*_property ();
//   3. export ()
{
 public:

  TAO_Property_Exporter (CosTrading::Lookup_var lookup_if,
			 CosPropertyService::PropertySet_ptr prop_set,
			 CORBA::ULong initial_size = 10);
  
  
  ~TAO_Property_Exporter (void);
  // Delete all Dynamic Property adapters
  
  void add_static_property (const char* name,
			    const CORBA::Any& value);
  // Add a property to the Offer and the PropSet.
  
  void add_dynamic_property (const char* name,
			     const CORBA::Any& intial_value,
			     TAO_Dynamic_Property& dp);
  // Add a property to the PropSet and a dynamic property to the
  // Offer. Have the dynamic property connect to the PropSet accessor
  // for that name. 

  void add_dynamic_property (const char* name,
			     CosTradingDynamic::DynamicProp& dp_struct);

  void add_dynamic_property (const char* name,
			     CosTradingDynamic::DynamicProp* dp_struct);
  
  CosTrading::OfferId export (const CORBA::Object_ptr object_ref,
			      const CosTrading::ServiceTypeName type,
			      CORBA::Environment& _env)
    TAO_THROW_SPEC ((CORBA::SystemException,
		     CosPropertyService::MultipleExceptions,
		     CosTrading::Register::InvalidObjectRef, 
		     CosTrading::IllegalServiceType, 
		     CosTrading::UnknownServiceType, 
		     CosTrading::Register::InterfaceTypeMismatch, 
		     CosTrading::IllegalPropertyName, 
		     CosTrading::PropertyTypeMismatch, 
		     CosTrading::ReadonlyDynamicProperty, 
		     CosTrading::MissingMandatoryProperty, 
		     CosTrading::DuplicatePropertyName));
  // Export the offer to the trader under the given type.
  
  typedef CosTradingRepos::ServiceTypeRepository TRADING_REPOS;
  CosTrading::OfferId export (const CORBA::Object_ptr object_ref,
			      const CosTrading::ServiceTypeName type,
			      const TRADING_REPOS::PropStructSeq& props,
			      const TRADING_REPOS::ServiceTypeNameSeq& stypes,
			      CORBA::Environment& _env)
    TAO_THROW_SPEC ((CORBA::SystemException,
		     CosPropertyService::MultipleExceptions,
		     CosTrading::IllegalServiceType, 
		     TRADING_REPOS::ServiceTypeExists, 
		     TRADING_REPOS::InterfaceTypeMismatch, 
		     CosTrading::IllegalPropertyName, 
		     CosTrading::DuplicatePropertyName, 
		     TRADING_REPOS::ValueTypeRedefinition, 
		     TRADING_REPOS::DuplicateServiceTypeName,
		     CosTrading::Register::InvalidObjectRef, 
		     CosTrading::Register::InterfaceTypeMismatch, 
		     CosTrading::ReadonlyDynamicProperty, 
		     CosTrading::MissingMandatoryProperty, 
		     CosTrading::DuplicatePropertyName));
  // Export the offer to the trader under the given type. Register the
  // type with the current definition if the type can't be found in
  // the service type repository.
  
private:
  
  TAO_Property_Exporter (const TAO_Property_Exporter&);
  void operator= (const TAO_Property_Exporter&);
  // These don't make sense on this class.

  const int increment_;
  
  CosTrading::Lookup_var lookup_;
  CosPropertyService::PropertySet_var prop_set_;

  CORBA::ULong pcount_, tcount_;  
  CosTrading::PropertySeq tprops_;
  CosPropertyService::Properties pprops_;
};

class TAO_Property_Modifier
// = TITLE
//   Modify or delete properties published in a PropSet instance or as
//   an offer in a Trading Service instance.
//
// = DESCRIPTION
//   This interface is primarily for properties registered as static
//   with the trading service, yet periodically change. The change
//   isn't frequent enough to warrant the constant overhead of dynamic
//   properties, which can affect the server performance.
{
public:

  TAO_Property_Modifier (CosTrading::Lookup_var lookup_if,
			 CosPropertyService::PropertySet_ptr prop_set,
			 CORBA::ULong initial_size = 10);

  // If no Lookup Interface is provided to the constructor, then
  // resolve_initial_references ("TradingService") will be used.

  void delete_property (const char* name);
  // Remove a property from the current prop_set/offer.
  
  void modify_property (const char* name, const CORBA::Any& value);
  // Modify a property from the current prop_set/offer.
  
  void commit (CosTrading::OfferId id, CORBA::Environment& _env)
    TAO_THROW_SPEC ((CORBA::SystemException,
		     CosPropertyService::MultipleExceptions,
		     CosTrading::NotImplemented, 
		     CosTrading::IllegalOfferId, 
		     CosTrading::UnknownOfferId, 
		     CosTrading::Register::ProxyOfferId, 
		     CosTrading::IllegalPropertyName, 
		     CosTrading::Register::UnknownPropertyName, 
		     CosTrading::PropertyTypeMismatch, 
		     CosTrading::ReadonlyDynamicProperty, 
		     CosTrading::Register::MandatoryProperty, 
		     CosTrading::Register::ReadonlyProperty, 
		     CosTrading::DuplicatePropertyName));
  // Commit your changes to the trading service.

 private:

  const int increment_;
  
  int pdcount_;
  int pmcount_;

  int tdcount_;
  int tmcount_;

  CosTrading::Lookup_var lookup_;
  CosPropertyService::PropertySet_var prop_set_;
  
  CosPropertyService::PropertyNames pdelete_;
  CosPropertyService::Properties pmodify_;
  
  CosTrading::PropertyNameSeq tdelete_;
  CosTrading::PropertySeq tmodify_;
  
  TAO_Property_Modifier (const TAO_Property_Modifier&);
  void operator= (const TAO_Property_Modifier&);
  // These don't make sense on this class.
};

#endif /* TAO_PROPERTY_EXPORTER_H */