3 //=============================================================================
7 * @author Vishal Kachroo <vishal@cs.wustl.edu>
9 //=============================================================================
15 #include "ace/Get_Opt.h"
16 #include "ace/Log_Msg.h"
17 #include "tao/Utils/ORB_Manager.h"
18 #include "orbsvcs/CosNamingC.h"
19 #include "orbsvcs/Naming/Naming_Client.h"
20 #include "orbsvcs/Time/TAO_Time_Service_Clerk.h"
25 * @brief CORBA Time Clerk implementation.
27 * A CORBA server that initializes the TimeService clerk
28 * implementation and the ORB.
35 // Pre-allocate slots for this many servers. The capacity grows on
37 DEFAULT_SERVER_COUNT
= 8
46 /// Set of available Time servers.
47 typedef ACE_Array_Base
<CosTime::TimeService_var
> IORS
;
49 /// Initialize the Clerk state - parsing arguments and waiting.
57 /// Insert a server in the internal data structure (servers_).
58 void insert_server (CosTime::TimeService_ptr server
);
62 /// Read the server IORs from a file instead of using a naming
64 int read_ior (const ACE_TCHAR
* filename
);
66 /// Parses the commandline arguments.
67 int parse_args (int argc
,
71 TAO_ORB_Manager orb_manager_
;
73 /// File where the IOR of the Clerk object is stored.
74 FILE *ior_output_file_
;
76 /// Initialises the name client and registers the <TimeService> Clerk
78 int init_naming_service ();
80 /// Create an instance of the clerk to use.
81 int create_clerk (void);
83 /// Bind the clerk in the appropriate context in the Naming Service.
84 int register_clerk (void);
86 /// Initialise the Interface Repository and register the clerk
87 /// implementation with it.
90 /// Get the reference to the server naming context and the first
92 int get_first_IOR (void);
94 /// Iterate over the given server context to get the rest of the
96 int next_n_IORs (CosNaming::BindingIterator_var iter
,
97 CosNaming::NamingContext_var server_context
);
100 * An instance of the name server used for registering the
101 * <TimeService Clerk> object. The same instance is used by the
102 * Clerk to periodically iterate through the Server Naming Context
103 * and get IORs of the available servers.
105 TAO_Naming_Client naming_client_
;
107 /// Implementation of the <TimeService> Clerk object.
108 TAO_Time_Service_Clerk
*time_service_clerk_impl_
;
110 /// Reference of the time service clerk.
111 CosTime::TimeService_var time_service_clerk_
;
113 /// Naming context for the Naming Service.
114 CosNaming::NamingContext_var time_service_clerk_context_
;
119 /// Clerk seeks time periodically after this interval in secs. from the
120 /// servers in the network.
123 /// Continues the precision of timer_value_ in microseconds.
124 int timer_value_usecs_
;
126 // IR_Helper *ir_helper_;
127 // Helper class for using the IR.
129 /// The unbounded set of server IORS.
132 /// Read IORs from a file.
136 #endif /* CLERK_I_H */