Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / orbsvcs / examples / Log / Basic / TLS_Client.cpp
blob6c2c98331c16a62f99a474b35a24dbd86a0d1fd2
1 #include "TLS_Client.h"
2 #include "ace/Log_Msg.h"
4 #define NAMING_SERVICE_NAME "NameService"
5 #define BASIC_TLS_LOG_FACTORY_NAME "BasicLogFactory"
6 #define LOG_EVENT_COUNT 9
7 #define QUERY_1 "id < 5"
8 #define QUERY_2 "id >= 0"
9 #define QUERY_LANG "TCL"
12 TLS_Client::TLS_Client ()
14 // No-Op.
17 TLS_Client::~TLS_Client ()
19 // No-Op.
22 void
23 TLS_Client::init (int argc, ACE_TCHAR *argv [])
25 init_ORB (argc, argv);
26 resolve_naming_service ();
27 resolve_TLS_Basic_factory ();
30 void
31 TLS_Client::init_ORB (int argc,
32 ACE_TCHAR *argv [])
34 this->orb_ = CORBA::ORB_init (argc, argv);
37 void
38 TLS_Client::resolve_naming_service ()
40 CORBA::Object_var naming_obj =
41 this->orb_->resolve_initial_references (NAMING_SERVICE_NAME);
43 // Need to check return value for errors.
44 if (CORBA::is_nil (naming_obj.in ()))
45 throw CORBA::UNKNOWN ();
47 this->naming_context_ =
48 CosNaming::NamingContext::_narrow (naming_obj.in ());
51 void
52 TLS_Client::resolve_TLS_Basic_factory ()
54 CosNaming::Name name (1);
55 name.length (1);
56 name[0].id = CORBA::string_dup (BASIC_TLS_LOG_FACTORY_NAME);
58 CORBA::Object_var obj =
59 this->naming_context_->resolve (name);
61 this->basic_log_factory_ =
62 DsLogAdmin::BasicLogFactory::_narrow (obj.in ());
65 void
66 TLS_Client::run_tests ()
68 ACE_ASSERT (!CORBA::is_nil (this->basic_log_factory_.in ()));
70 // create a log..
72 ACE_DEBUG ((LM_DEBUG,
73 "\nCalling BasicLogFactory::create...\n"));
75 DsLogAdmin::LogFullActionType logfullaction = DsLogAdmin::halt;
76 CORBA::ULongLong max_size = 0; // 0 means "infinite"
78 DsLogAdmin::LogId logid = 0;
80 DsLogAdmin::BasicLog_var basic_log =
81 this->basic_log_factory_->create (logfullaction,
82 max_size,
83 logid);
85 ACE_DEBUG ((LM_DEBUG,
86 "Create returned logid = %d\n",logid));
88 // Create some fake log events.
89 DsLogAdmin::Anys any_seq (LOG_EVENT_COUNT);
90 any_seq.length (LOG_EVENT_COUNT);
92 for (int i = 0; i < LOG_EVENT_COUNT; i++)
94 any_seq [i] <<= "Foo";
97 ACE_DEBUG ((LM_DEBUG,
98 "Writing %d records...\n", LOG_EVENT_COUNT));
99 basic_log->write_records (any_seq);
101 ACE_DEBUG ((LM_DEBUG,
102 "Calling BasicLog::get_n_records...\n"));
103 CORBA::ULongLong retval = basic_log->get_n_records ();
105 ACE_DEBUG ((LM_DEBUG, "Number of records in Log = %d\n", retval));
107 ACE_DEBUG ((LM_DEBUG,
108 "Calling BasicLog::get_current_size...\n"));
109 retval = basic_log->get_current_size ();
111 ACE_DEBUG ((LM_DEBUG, "Size of data in Log = %d\n", retval));
113 ACE_DEBUG ((LM_DEBUG, "Querying the Log: %s\n", QUERY_1));
114 DsLogAdmin::Iterator_var iter_out;
115 DsLogAdmin::RecordList_var rec_list =
116 basic_log->query (QUERY_LANG, QUERY_1, iter_out);
118 CORBA::ULong j = 0;
119 for (; j < rec_list->length();++j) //dhanvey added info
120 ACE_DEBUG ((LM_DEBUG,
121 "id = %Q, time= %Q\n",
122 rec_list[j].id, rec_list[j].time));
124 ACE_DEBUG ((LM_DEBUG,
125 "Deleting records...\n"));
127 retval = basic_log->delete_records (QUERY_LANG, QUERY_2);
129 ACE_DEBUG ((LM_DEBUG,
130 "Calling BasicLog::get_n_records...\n"));
131 retval = basic_log->get_n_records ();
133 ACE_DEBUG ((LM_DEBUG, "Number of records in Log after delete = %d\n",
134 retval));
136 ACE_DEBUG ((LM_DEBUG, "Geting the current_size again...\n"));
137 retval = basic_log->get_current_size ();
139 ACE_DEBUG ((LM_DEBUG, "Size of data in Log = %d\n", retval));
141 basic_log->destroy ();