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
|
// $Id$
#include "_pch.h"
#include "Message_i.h"
#include "MessengerC.h"
#include "tao/AnyTypeCode/TypeCode.h"
#include <iostream>
MessageImpl::MessageImpl()
{
}
MessageImpl::~MessageImpl()
{
}
MessageImpl::MessageImpl
(Message::AddrList &address,
const char* user,
const char* subject,
const char* txt
) : OBV_Message(address, user, subject, txt)
{
}
MessageImpl::MessageImpl
(const char* address,
const char* user,
const char* subject,
const char* txt
) : OBV_Message(Message::AddrList(), user, subject, txt)
{
addAddress(address);
}
::CORBA::ValueBase *
MessageImpl::_copy_value (void)
{
::CORBA::ValueBase *ret_val= 0;
ACE_NEW_THROW_EX (
ret_val,
MessageImpl (
addrs_ (),
user (),
subject (),
text ()
),
::CORBA::NO_MEMORY ()
);
return ret_val;
}
Message::AddrList* MessageImpl::getAddresses() {
return new AddrList(addrs_());
}
void MessageImpl::addAddress(const char* s) {
AddrList& al = addrs_();
CORBA::ULong idx = al.length();
al.length(idx + 1);
al[idx] = s;
}
char* MessageImpl::user() {
return CORBA::string_dup(user_());
}
void MessageImpl::user(const char* s) {
user_(s);
}
char* MessageImpl::subject() {
return CORBA::string_dup(subject_());
}
void MessageImpl::subject(const char* s) {
subject_(s);
}
char* MessageImpl::text() {
return CORBA::string_dup(text_());
}
void MessageImpl::text(const char* s) {
text_(s);
}
void MessageImpl::print() {
std::cout << "Message from : " << user_() << std::endl;
AddrList& addrs = addrs_();
if (addrs.length() > 0) {
std::cout << "\tTo : ";
for (CORBA::ULong i = 0; i < addrs.length(); ++i) {
CORBA::String_var s = CORBA::string_dup(addrs[i]);
std::cout << s.in() << ";";
}
std::cout << std::endl;
}
std::cout << "\tSubject : " << subject_() << std::endl;
std::cout << "\tText : " << text_() << std::endl;
}
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
void
MessageFactory::register_new_factory(CORBA::ORB& orb) {
CORBA::ValueFactoryBase_var mf = new MessageFactory;
CORBA::String_var id = _tc_Message->id();
orb.register_value_factory(id.in(), mf.in());
}
CORBA::ValueBase*
MessageFactory::create_for_unmarshal()
{
return new MessageImpl;
}
|