summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Trader/Admin.cpp
blob: c8e5b4092639b8e60fe3069ea5fc34d73376245b (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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
/* -*- C++ -*- */

// ============================================================================
// $Id$
//
// = LIBRARY
//    Admin
// 
// = FILENAME
//    Admin.cpp
//
// = AUTHOR
//    Marina Spivak <marina@cs.wustl.edu>
//    Seth Widoff <sbw1@cs.wustl.edu>
// 
// ============================================================================

#if !defined (TAO_ADMIN_C)
#define TAO_ADMIN_C

#include "Admin.h"

template <class TRADER>
const char* TAO_Admin<TRADER>::NAME = "Trader: Admin";

template <class TRADER>  
TAO_Admin<TRADER>::TAO_Admin (TRADER &trader)
  : trader_ (trader),
    TAO_Trader_Components <POA_CosTrading::Admin> (trader.trading_components ()),
    TAO_Import_Attributes <POA_CosTrading::Admin> (trader.import_attributes ()),
    TAO_Support_Attributes <POA_CosTrading::Admin> (trader.support_attributes ()),
    TAO_Link_Attributes <POA_CosTrading::Admin> (trader.link_attributes ()),
    sequence_number_ (0)
{
  // Because a servant is uniquely identified by a POA name and an
  // ObjectID number, the concatenation of the two prefixed before a
  // sequence number will ensure the request_id_stem space between
  // traders will not overlap. The sequence number space will be four
  // octets.
  CORBA::Environment _env;
  PortableServer::POA_var poa = this->_default_POA (_env);
  PortableServer::ObjectId_var id = poa->servant_to_id (this, _env);
  CORBA::String_var poa_name = poa->the_name (_env);
  int name_length = ACE_OS::strlen (poa_name.in ()),
    id_length = id->length (),
    total_length = name_length + id_length + sizeof (CORBA::ULong);
  
  this->stem_id_.length (total_length);
  // @@ Commented it out until a fix is found
  
  for (int i = total_length - 1, j = name_length - 1; j >= 0; i--, j--) 
    //this->stem_id_[i] = (CORBA::Octet) poa_name[j];
    ;


  for (j = id_length - 1; j >= 0; j--, i--)
    this->stem_id_[i] = id[j];
}

template <class TRADER>
TAO_Admin<TRADER>::~TAO_Admin (void)
{
}

template <class TRADER> CosTrading::Admin::OctetSeq * 
TAO_Admin<TRADER>::request_id_stem (CORBA::Environment& _env)
  TAO_THROW_SPEC ((CORBA::SystemException))
{
  // Add one to the sequence_number and concatenate it to the unique
  // prefix. The sequence number is four octets long.
  for (int i = sizeof (CORBA::ULong) - 1; i >= 0; i--)
    this->stem_id_[i] = (this->sequence_number_ >> (8*i)) & 0xff;

  // Increment the sequence number and return a copy of the stem_id.
  this->sequence_number_++;
  return new CosTrading::Admin::OctetSeq (this->stem_id_);
}

template <class TRADER> CORBA::ULong 
TAO_Admin<TRADER>::set_def_search_card (CORBA::ULong value,
					CORBA::Environment& _env)
  TAO_THROW_SPEC ((CORBA::SystemException)) 
{
  CORBA::ULong return_value =
    this->trader_.import_attributes ().def_search_card ();

  this->trader_.import_attributes ().def_search_card (value);
  return return_value;
}

template <class TRADER> CORBA::ULong 
TAO_Admin<TRADER>::set_max_search_card (CORBA::ULong value,
					CORBA::Environment& _env)
  TAO_THROW_SPEC ((CORBA::SystemException))
{
  CORBA::ULong return_value =
    this->trader_.import_attributes ().max_search_card ();

  this->trader_.import_attributes ().max_search_card (value);
  return return_value;
}

template <class TRADER> CORBA::ULong 
TAO_Admin<TRADER>::set_def_match_card (CORBA::ULong value,
				       CORBA::Environment& _env)
  TAO_THROW_SPEC ((CORBA::SystemException))
{
  CORBA::ULong return_value =
    this->trader_.import_attributes ().def_match_card ();

  this->trader_.import_attributes ().def_match_card (value);
  return return_value;
}

template <class TRADER> CORBA::ULong 
TAO_Admin<TRADER>::set_max_match_card (CORBA::ULong value,
				       CORBA::Environment& _env)
  TAO_THROW_SPEC ((CORBA::SystemException))
{
  CORBA::ULong return_value =
    this->trader_.import_attributes ().max_match_card ();

  this->trader_.import_attributes ().max_match_card (value);
  return return_value;
}

template <class TRADER> CORBA::ULong 
TAO_Admin<TRADER>::set_def_return_card (CORBA::ULong value,
					CORBA::Environment& _env)
  TAO_THROW_SPEC ((CORBA::SystemException))
{
  CORBA::ULong return_value =
    this->trader_.import_attributes ().def_return_card ();
  
  this->trader_.import_attributes ().def_return_card (value);
  return return_value;
}

template <class TRADER> CORBA::ULong 
TAO_Admin<TRADER>::set_max_return_card (CORBA::ULong value,
					CORBA::Environment& _env)
  TAO_THROW_SPEC ((CORBA::SystemException))
{
  CORBA::ULong return_value =
    this->trader_.import_attributes ().max_return_card ();
  
  this->trader_.import_attributes ().max_return_card (value);
  return return_value;
}

template <class TRADER> CORBA::ULong 
TAO_Admin<TRADER>::set_max_list (CORBA::ULong value,
				 CORBA::Environment& _env)
  TAO_THROW_SPEC ((CORBA::SystemException))
{
  CORBA::ULong return_value =
    this->trader_.import_attributes ().max_list ();
  
  this->trader_.import_attributes ().max_list (value);
  return return_value;
}

template <class TRADER> CORBA::Boolean 
TAO_Admin<TRADER>::
set_supports_modifiable_properties (CORBA::Boolean value,
				    CORBA::Environment& _env)
  TAO_THROW_SPEC ((CORBA::SystemException))
{
  CORBA::Boolean return_value =
    this->trader_.support_attributes ().supports_modifiable_properties ();
  
  this->trader_.support_attributes ().supports_modifiable_properties (value);
  return return_value;
}

template <class TRADER> CORBA::Boolean 
TAO_Admin<TRADER>::
set_supports_dynamic_properties (CORBA::Boolean value,
				 CORBA::Environment& _env)
  TAO_THROW_SPEC ((CORBA::SystemException))
{
  CORBA::Boolean return_value =
    this->trader_.support_attributes ().supports_dynamic_properties ();
  
  this->trader_.support_attributes ().supports_dynamic_properties (value);
  return return_value;
}

template <class TRADER> CORBA::Boolean 
TAO_Admin<TRADER>::set_supports_proxy_offers (CORBA::Boolean value,      
					      CORBA::Environment& _env)
  TAO_THROW_SPEC ((CORBA::SystemException))
{
  CORBA::Boolean return_value =
    this->trader_.support_attributes ().supports_proxy_offers ();
  
  this->trader_.support_attributes ().supports_proxy_offers (value);
  return return_value;
}

template <class TRADER> CORBA::ULong 
TAO_Admin<TRADER>::set_def_hop_count (CORBA::ULong value,
				      CORBA::Environment& _env)
  TAO_THROW_SPEC ((CORBA::SystemException))
{
  CORBA::ULong return_value =
    this->trader_.import_attributes ().def_hop_count ();
  
  this->trader_.import_attributes ().def_hop_count (value);
  return return_value;
}

template <class TRADER> CORBA::ULong 
TAO_Admin<TRADER>::set_max_hop_count (CORBA::ULong value,
				      CORBA::Environment& _env)
  TAO_THROW_SPEC ((CORBA::SystemException))
{
  CORBA::ULong return_value =
    this->trader_.import_attributes ().max_hop_count ();
    
  this->trader_.import_attributes ().max_hop_count (value);
  return return_value;
}

template <class TRADER> CosTrading::FollowOption 
TAO_Admin<TRADER>::set_def_follow_policy (CosTrading::FollowOption policy,
					  CORBA::Environment& _env)
  TAO_THROW_SPEC ((CORBA::SystemException))
{
  CosTrading::FollowOption return_value =
    this->trader_.import_attributes ().def_follow_policy ();
    
  this->trader_.import_attributes ().def_follow_policy (policy);
  return return_value;
}

template <class TRADER> CosTrading::FollowOption 
TAO_Admin<TRADER>::set_max_follow_policy (CosTrading::FollowOption policy,
					  CORBA::Environment& _env)
  TAO_THROW_SPEC ((CORBA::SystemException))
{
  CosTrading::FollowOption return_value =
    this->trader_.import_attributes ().max_follow_policy ();
    
  this->trader_.import_attributes ().max_follow_policy (policy);
  return return_value;
}

template <class TRADER> CosTrading::FollowOption 
TAO_Admin<TRADER>::
set_max_link_follow_policy (CosTrading::FollowOption policy,
			    CORBA::Environment& _env)
  TAO_THROW_SPEC ((CORBA::SystemException))
{
  CosTrading::FollowOption return_value =
    this->trader_.link_attributes ().max_link_follow_policy ();
  
  this->trader_.link_attributes ().max_link_follow_policy (policy);
  return return_value;
}

template <class TRADER> CosTrading::TypeRepository_ptr 
TAO_Admin<TRADER>::
set_type_repos (CosTrading::TypeRepository_ptr repository,
		CORBA::Environment& _env)
  TAO_THROW_SPEC ((CORBA::SystemException))
{
  CosTrading::TypeRepository_ptr return_value =
    this->trader_.support_attributes ().type_repos ();
  
  this->trader_.support_attributes ().type_repos (repository);
  return return_value;
}

template <class TRADER> CosTrading::Admin::OctetSeq* 
TAO_Admin<TRADER>::set_request_id_stem (const CosTrading::Admin::OctetSeq& stem,
					CORBA::Environment& _env)
  TAO_THROW_SPEC ((CORBA::SystemException))
{
  return 0;
}

template <class TRADER> void 
TAO_Admin<TRADER>::list_offers (CORBA::ULong how_many, 
				CosTrading::OfferIdSeq_out ids, 
				CosTrading::OfferIdIterator_out id_itr,
				CORBA::Environment& _env)
  TAO_THROW_SPEC ((CORBA::SystemException,) 
		  CosTrading::NotImplemented)
{
  // This method only applies when the register interface is implemented
  if (CORBA::is_nil(this->trader_.trading_components().register_if()))
    TAO_THROW (CosTrading::NotImplemented());

  TRADER::Service_Type_Map& type_map = this->trader_.service_type_map();

  CosTrading::OfferIdIterator_ptr oi =
    type_map.retrieve_all_offer_ids ()->_this (_env);
  TAO_CHECK_ENV_RETURN_VOID (_env);
      
  id_itr = CosTrading::OfferIdIterator::_nil ();
  if (how_many > 0)
    {      
      if (oi->next_n (how_many, ids, _env) == CORBA::B_FALSE)
	{
	  // No more items left in the iterator.
	  oi->destroy (_env);
	  oi = CosTrading::OfferIdIterator::_nil ();
	}
      else
	id_itr = oi;
    }
  else
    ids = new CosTrading::OfferIdSeq(0);
}

template <class TRADER> void 
TAO_Admin<TRADER>::list_proxies (CORBA::ULong how_many, 
				 CosTrading::OfferIdSeq_out ids, 
				 CosTrading::OfferIdIterator_out id_itr,
				 CORBA::Environment& _env) 
  TAO_THROW_SPEC ((CORBA::SystemException,
		  CosTrading::NotImplemented))
{
  TAO_THROW (CosTrading::NotImplemented ());
}

#endif /* TAO_ADMIN_C */