Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / DevGuideExamples / SmartProxies / Smart_Messenger_Proxy.cpp
blobf0e3d7c8312ea95a899c7697f4c5779c926f0325
1 // Smart_Messenger_Proxy.cpp
3 #include "Smart_Messenger_Proxy.h"
4 #include <iostream>
6 Smart_Messenger_Proxy_Factory::Smart_Messenger_Proxy_Factory(
7 CORBA::ORB_ptr orb)
9 std::cout << "Creating smart proxy factory" << std::endl;
10 // Convert the contents of the Logger.ior file to an object reference.
11 CORBA::Object_var obj = orb->string_to_object("file://Logger.ior");
12 if (CORBA::is_nil(obj.in())) {
13 std::cerr << "Nil Logger reference" << std::endl;
14 throw 0;
17 // Narrow the object reference to a Logger object reference.
18 logger_ = Logger::_narrow(obj.in());
19 if (CORBA::is_nil(logger_.in ())) {
20 std::cerr << "Not a Logger object reference" << std::endl;
21 throw 0;
25 Messenger_ptr
26 Smart_Messenger_Proxy_Factory::create_proxy (
27 Messenger_ptr proxy)
29 Messenger_ptr smart_proxy = 0;
30 if (CORBA::is_nil(proxy) == 0)
31 smart_proxy = new Smart_Messenger_Proxy(proxy, logger_.in());
32 return smart_proxy;
36 Smart_Messenger_Proxy::Smart_Messenger_Proxy(
37 Messenger_ptr proxy, Logger_ptr logger)
38 : TAO_Smart_Proxy_Base(proxy),
39 logger_(Logger::_duplicate(logger))
41 std::cout << "Creating smart proxy" << std::endl;
44 CORBA::Boolean
45 Smart_Messenger_Proxy::send_message (
46 const char * user_name,
47 const char * subject,
48 char *& message)
50 logger_->log_message("Before send_message()");
51 CORBA::Boolean ret_val =
52 TAO_Messenger_Smart_Proxy_Base::send_message(user_name, subject, message);
53 logger_->log_message("After send_message()");
54 return ret_val;