summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Trader/Trader_T.h
blob: a88372d8f2a5ae696c93d3e8c0e9d32719d3ebb3 (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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
/* -*- C++ -*- */

// ========================================================================
// $Id$
// 
// = LIBRARY
//    orbsvcs
// 
// = FILENAME
//    Trader.h
//
// = AUTHOR
//    Marina Spivak <marina@cs.wustl.edu>
//    Seth Widoff <sbw1@cs.wustl.edu>
//    Irfan Pyarali <irfan@cs.wustl.edu>
//   
// ========================================================================

#ifndef TAO_TRADER_H
#define TAO_TRADER_H

#include "Trader.h"
#include "Offer_Database.h"

  // *************************************************************
  // TAO_Trader
  // *************************************************************

template <class TRADER_LOCK_TYPE, class MAP_LOCK_TYPE>
class TAO_Trader : public TAO_Trader_Base
  //
  // = TITLE
  //     This class packages together all the various pieces that
  //     provide functionality specified in COS Trading specification.
  //
  // = DESCRIPTION
  //     TAO_Trader contains all the components that together represent
  //     a single trader.  Based on its constructor arguments, 
  //     TAO_Trader creates instances of appropriate interface 
  //     implementations as well as instances of objects common to
  //     more than one interface (offers, attributes, etc.).
  //     TAO_Trader also enforces the proper order on all
  //     initializations.  TAO_Trader acts like a "glue" class that
  //     creates appropriate components, holds everything together,
  //     and enforces order. TAO_Trader is parameterized by two types
  //     of locks: one for its service service offers, one for its
  //     state (configuration). 
{    
public:

  // The desired combination of interfaces to be passed to the 
  // TAO_Trader constructor.

  typedef TAO_Offer_Database<MAP_LOCK_TYPE> Offer_Database;
  // Offer Database Trait.

  TAO_Trader (Trader_Components components = LOOKUP);
  // Constructor which based on its arguments will create 
  // a particular type of trader (e.g. Query trader, Simple trader, etc.)
  // The argument is a bitwise OR of desired Trader_Components as listed
  // in enumerated type above.

  virtual ~TAO_Trader (void);
  // destructor.
  
  Offer_Database& offer_database (void);
  // Accessor for the structure with all the service offers.

  ACE_Lock &lock (void);
  // returns the trader
  
protected: 
  
  typedef TAO_Trader<TRADER_LOCK_TYPE, MAP_LOCK_TYPE> TRADER_SELF;
  
  Offer_Database offer_database_; 

  ACE_Lock_Adapter<TRADER_LOCK_TYPE> lock_;
  // lock that guards the state of the trader (its configuration).

  enum { LOOKUP_IF, REGISTER_IF, ADMIN_IF, PROXY_IF, LINK_IF };
  
  PortableServer::ServantBase* ifs_[5];
  
private:
  
  // = Disallow these operations.
  ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_Trader<TRADER_LOCK_TYPE, MAP_LOCK_TYPE> &))
};

  // *************************************************************
  // Template Attribute Classes
  // *************************************************************

template <class IF>
class TAO_Trader_Components : public virtual IF
{
public:

  TAO_Trader_Components (const TAO_Trading_Components_Impl& comps);
  
  // = CosTrading::TraderComponents methods. 
  virtual CosTrading::Lookup_ptr lookup_if (CORBA::Environment& env)
    TAO_THROW_SPEC ((CORBA::SystemException));
  // Returns an object reference to the Lookup interface of the trader.
  // Returns nil if the trader does not support Lookup interface.
  
  virtual CosTrading::Register_ptr register_if (CORBA::Environment& env)
    TAO_THROW_SPEC ((CORBA::SystemException));
  // Returns object reference for the Register interface of the trader.
  // Returns nil if the trader does not support Register interface.
  
  virtual CosTrading::Link_ptr link_if (CORBA::Environment& env)
    TAO_THROW_SPEC ((CORBA::SystemException)); 
  // Returns object reference for the Link interface of the trader.
  // Returns nil if the trader does not support Link interface.

  virtual CosTrading::Proxy_ptr proxy_if (CORBA::Environment& env)
    TAO_THROW_SPEC ((CORBA::SystemException));
  // Returns object reference to the Proxy interface of the trader.
  // Returns nil if the trader does not support Proxy interface. 
   
  virtual CosTrading::Admin_ptr admin_if (CORBA::Environment& env)
    TAO_THROW_SPEC ((CORBA::SystemException));
  // Returns object reference for the Admin interface of the trader.
  // Returns nil if the trader does not support Admin interface.

private:
  
  const TAO_Trading_Components_Impl& comps_;
};

template <class IF>
class TAO_Support_Attributes : public virtual IF
{
public:

  TAO_Support_Attributes (const TAO_Support_Attributes_Impl& attrs);

  // = CosTrading::SupportAttributes methods.
  
  virtual CORBA::Boolean supports_modifiable_properties (CORBA::Environment& env)
    TAO_THROW_SPEC ((CORBA::SystemException));
  
  virtual CORBA::Boolean supports_dynamic_properties (CORBA::Environment& env)
    TAO_THROW_SPEC ((CORBA::SystemException));
  
  virtual CORBA::Boolean supports_proxy_offers (CORBA::Environment& env)
    TAO_THROW_SPEC ((CORBA::SystemException));
  
  virtual CosTrading::TypeRepository_ptr type_repos (CORBA::Environment& env)
    TAO_THROW_SPEC ((CORBA::SystemException));
  
private:

  const TAO_Support_Attributes_Impl& attrs_;
};

template <class IF>
class TAO_Import_Attributes : public virtual IF
{
public:

  TAO_Import_Attributes (const TAO_Import_Attributes_Impl& attrs);

  // = CosTrading::ImportAttributes methods.
  
  virtual CORBA::ULong def_search_card (CORBA::Environment& env)
    TAO_THROW_SPEC ((CORBA::SystemException));

  virtual CORBA::ULong max_search_card (CORBA::Environment& env)
    TAO_THROW_SPEC ((CORBA::SystemException));

  // Search cardinality determines the maximum number of offers searched
  // before not considering other offers. 
  
  virtual CORBA::ULong def_match_card (CORBA::Environment& env)
    TAO_THROW_SPEC ((CORBA::SystemException));

  virtual CORBA::ULong max_match_card (CORBA::Environment& env)
    TAO_THROW_SPEC ((CORBA::SystemException));

  // Match cardinality determines the maximum number of offers
  // matched to the constraints before not considering other offers..
  
  virtual CORBA::ULong def_return_card (CORBA::Environment& env)
    TAO_THROW_SPEC ((CORBA::SystemException));

  virtual CORBA::ULong max_return_card (CORBA::Environment& env)
    TAO_THROW_SPEC ((CORBA::SystemException));

  // Return cardinality determines the maximum number of offers marked 
  // to return before not considering other offers.

  
  virtual CORBA::ULong max_list (CORBA::Environment& env)
    TAO_THROW_SPEC ((CORBA::SystemException));

  virtual CORBA::ULong def_hop_count (CORBA::Environment& env)
    TAO_THROW_SPEC ((CORBA::SystemException));

  virtual CORBA::ULong max_hop_count (CORBA::Environment& env)
    TAO_THROW_SPEC ((CORBA::SystemException));

  virtual CosTrading::FollowOption def_follow_policy (CORBA::Environment& env)
    TAO_THROW_SPEC ((CORBA::SystemException));

  virtual CosTrading::FollowOption max_follow_policy (CORBA::Environment& env)
    TAO_THROW_SPEC ((CORBA::SystemException));

  
private:

  const TAO_Import_Attributes_Impl& attrs_;
};

template <class IF>
class TAO_Link_Attributes : public virtual IF
{
public:

  TAO_Link_Attributes (const TAO_Link_Attributes_Impl& attrs);

  // = CosTrading::LinkAttributes methods
  virtual CosTrading::FollowOption max_link_follow_policy (CORBA::Environment &env)
    TAO_THROW_SPEC ((CORBA::SystemException));
    
private:

  const TAO_Link_Attributes_Impl& attrs_;
};

  // *************************************************************
  // TAO_Sequence_Extracter
  // *************************************************************

template <class SEQ_TYPE>
class TAO_Sequence_Extracter : private TAO_Sequence_Extracter_Base
// = TITLE
//  Happy hack to extract sequence data out of user defined sequence
//  that may have x number of typedef aliases. 
{
 public:

  TAO_Sequence_Extracter (CORBA::TypeCode* type_code)
    : typecode_ (CORBA::TypeCode::_duplicate (type_code)) {}
  
  CORBA::Boolean extract (const CORBA::Any&, SEQ_TYPE*&);
  // Extract the underlying sequence value into a newly allocated
  // sequence of type SEQ_TYPE. The any assumes ownership of the
  // sequence, so don't release it.
  
 private:
  
  CORBA::TypeCode_var typecode_;
};


template <class SEQ, class OPERAND_TYPE>
CORBA::Boolean TAO_find (const SEQ& sequence, const OPERAND_TYPE operand);

#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
#include "Trader_T.cpp"
#endif  /* ACE_TEMPLATES_REQUIRE_SOURCE */

#endif /* ACE_TRADER_H */