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
|
// ============================================================================
// $Id$
//
// = LIBRARY
// orbsvcs
//
// = FILENAME
// Offer_Id_terator.cpp
//
// = AUTHOR
// Seth Widoff <sbw1@cs.wustl.edu>
//
// ============================================================================
#include "Offer_Id_Iterator.h"
TAO_Offer_Id_Iterator::TAO_Offer_Id_Iterator (void)
{
}
TAO_Offer_Id_Iterator::~TAO_Offer_Id_Iterator (void)
{
int items_left = this->ids_.size (),
return_value = 0;
do
{
CosTrading::OfferId offer_id = 0;
return_value = this->ids_.dequeue_head (offer_id);
if (return_value == 0)
CORBA::string_free (offer_id);
}
while (return_value == 0);
}
CORBA::ULong
TAO_Offer_Id_Iterator::max_left (CORBA::Environment& env)
TAO_THROW_SPEC ((CORBA::SystemException,
CosTrading::UnknownMaxLeft))
{
return this->ids_.size ();
}
void
TAO_Offer_Id_Iterator::destroy (CORBA::Environment& _env)
TAO_THROW_SPEC ((CORBA::SystemException))
{
// Remove self from POA
//
// Note that there is no real error checking here as we can't do
// much about errors here anyway
//
TAO_TRY
{
PortableServer::POA_var poa = this->_default_POA (TAO_TRY_ENV);
TAO_CHECK_ENV;
PortableServer::ObjectId_var id = poa->servant_to_id (this, TAO_TRY_ENV);
TAO_CHECK_ENV;
poa->deactivate_object (id.in (), TAO_TRY_ENV);
}
TAO_CATCHANY
{
}
TAO_ENDTRY;
delete this;
}
CORBA::Boolean
TAO_Offer_Id_Iterator::next_n (CORBA::ULong n,
CosTrading::OfferIdSeq_out _ids,
CORBA::Environment& _env)
TAO_THROW_SPEC ((CORBA::SystemException))
{
// Calculate the number of Ids to be returned in this.
int items_left = this->ids_.size(),
difference = items_left - n,
returnable_items = (difference >= 0) ? n : items_left;
CORBA::Boolean return_value = (CORBA::Boolean) (difference > 0);
if (returnable_items == 0)
{
ACE_NEW_RETURN (_ids, CosTrading::OfferIdSeq, return_value);
}
else
{
// Allocate space for the returned OfferIds.
CosTrading::OfferId* id_buf =
CosTrading::OfferIdSeq::allocbuf (returnable_items);
if (id_buf != 0)
{
// Copy in those ids!
for (int i = 0; i < returnable_items; i++)
{
CosTrading::OfferId offer_id = 0;
this->ids_.dequeue_head (offer_id);
id_buf[i] = offer_id;
}
// Place them into an OfferIdSeq.
ACE_NEW_RETURN (_ids,
CosTrading::OfferIdSeq (returnable_items,
returnable_items,
id_buf,
1),
return_value);
}
else
ACE_NEW_RETURN (_ids, CosTrading::OfferIdSeq, return_value);
}
// Return true only if there are items left to be returned in
// subsequent calls.
return return_value;
}
void
TAO_Offer_Id_Iterator::insert_id (CosTrading::OfferId new_id)
{
this->ids_.enqueue_tail (new_id);
}
|