blob: 66cfd22ad295fa7180a641616eeab5a137ce6a74 (
plain)
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
|
// -*- C++ -*-
// $Id$
#include <iostream>
#include <fstream>
#include <string>
#include <iterator>
#include <algorithm>
#include "orbsvcs/orbsvcs/LWFT/HostMonitorImpl.h"
#include "orbsvcs/orbsvcs/LWFT/Monitor_Thread.h"
#include "orbsvcs/orbsvcs/LWFT/HMOptions.h"
#include "orbsvcs/orbsvcs/LWFT/LWFT_Client_Init.h"
int main (int argc, char* argv[])
{
try
{
/// First initialize the ORB, that will remove some arguments...
LWFT_Client_Init ci;
CORBA::ORB_var orb = ci.init (argc, argv);
/// Initilize RootPOA.
CORBA::Object_var poa_object =
orb->resolve_initial_references ("RootPOA");
/// Create the POA object reference to type POA.
PortableServer::POA_var poa =
PortableServer::POA::_narrow (poa_object.in ());
/// Activate the POA manager.
PortableServer::POAManager_var poa_manager =
poa->the_POAManager ();
poa_manager->activate ();
HMOptions *opts = HMOptions::instance ();
if (! opts->parse_args (argc, argv))
{
ACE_ERROR_RETURN ((LM_ERROR,
"Host Monitor options "
"are incorrect.\n"),
-1);
}
Monitor_Thread monitor_thread;
/// Initilize the timedate object on heap.
HostMonitorImpl * host_monitor =
new HostMonitorImpl (orb, &monitor_thread);
PortableServer::ServantBase_var safe_host (host_monitor);
ACE_UNUSED_ARG (safe_host);
HostMonitor_var hmvar = host_monitor->_this ();
CORBA::String_var hmstr = orb->object_to_string (hmvar.in ());
/// Copy the IOR in the IORFILE.
std::string ior_file (opts->HM_ior_file ());
std::ofstream outfile (ior_file.c_str ());
outfile << hmstr;
outfile.close ();
monitor_thread.activate ();
orb->run ();
/// Destroy the POA, waiting until the destruction terminates
poa->destroy (true, true);
orb->destroy ();
}
catch (CORBA::Exception &ex)
{
ACE_PRINT_EXCEPTION (ex, "A CORBA exception was raised:");
return -1;
}
return 0;
}
|