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
|
//
// **** Code generated by the ****
// **** Component Integrated ACE ORB (CIAO) CIDL Compiler ****
// CIAO has been developed by:
// Center for Distributed Object Computing
// Washington University
// St. Louis, MO
// USA
// http://www.cs.wustl.edu/~schmidt/doc-center.html
// CIDL Compiler has been developed by:
// Institute for Software Integrated Systems
// Vanderbilt University
// Nashville, TN
// USA
// http://www.isis.vanderbilt.edu/
//
// Information about CIAO is available at:
// http://www.dre.vanderbilt.edu/CIAO
#include "History_exec_i.h"
namespace CIAO_Messenger_Impl
{
//==================================================================
// Facet Executor Implementation Class: History_exec_i
//==================================================================
History_exec_i::History_exec_i (void)
{
}
History_exec_i::~History_exec_i (void)
{
}
// Operations from ::History
::Messages *
History_exec_i::get_all ()
{
// Your code here.
// MY CODE
ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);
ACE_DEBUG((LM_INFO, ACE_TEXT("History_i::get_all\n") ));
// create a Messages sequence, set its length
::Messages* retval = new ::Messages();
retval->length( this->messages_.size() );
// iterate through the MessageList, copying messages into the return sequence
CORBA::ULong i = 0;
for ( MessageList::iterator messageItr = this->messages_.begin();
messageItr != this->messages_.end();
++messageItr )
{
// because the MessageList contains Message_vars, reference counting
// upon assignment into the sequence is handled properly for us.
(*retval)[i++] = *messageItr;
}
return retval;
}
::Message *
History_exec_i::get_latest ()
{
// Your code here.
// MY CODE
ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);
ACE_DEBUG((LM_INFO, ACE_TEXT("History_i::get_latest\n") ));
// just get the last message from the history. because the MessageList
// contains Message_vars, _var to _var assigmnent handles the reference
// counting properly for us.
::Message_var retval = this->messages_.back();
return retval._retn();
}
// MY CODE
void
History_exec_i::add( ::Message* message )
{
ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_);
// bump up the reference count; we don't own it.
// the _var in the STL list takes ownership of the "copy"
message->_add_ref();
this->messages_.push_back(message);
}
}
|