Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / orbsvcs / Time_Service / Clerk_i.h
bloba811aff45c7d95d299387406c612ca9f58f97f7d
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Clerk_i.h
7 * @author Vishal Kachroo <vishal@cs.wustl.edu>
8 */
9 //=============================================================================
12 #ifndef CLERK_I_H
13 #define CLERK_I_H
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"
22 /**
23 * @class Clerk_i
25 * @brief CORBA Time Clerk implementation.
27 * A CORBA server that initializes the TimeService clerk
28 * implementation and the ORB.
30 class Clerk_i
32 public:
34 enum {
35 // Pre-allocate slots for this many servers. The capacity grows on
36 // demand.
37 DEFAULT_SERVER_COUNT = 8
40 /// Constructor.
41 Clerk_i (void);
43 /// Destructor.
44 ~Clerk_i (void);
46 /// Set of available Time servers.
47 typedef ACE_Array_Base<CosTime::TimeService_var> IORS;
49 /// Initialize the Clerk state - parsing arguments and waiting.
50 int init (int argc,
51 ACE_TCHAR *argv[]);
53 /// Run the orb.
54 int run (void);
56 private:
57 /// Insert a server in the internal data structure (servers_).
58 void insert_server (CosTime::TimeService_ptr server);
60 private:
62 /// Read the server IORs from a file instead of using a naming
63 /// service.
64 int read_ior (const ACE_TCHAR* filename);
66 /// Parses the commandline arguments.
67 int parse_args (int argc,
68 ACE_TCHAR* argv[]);
70 /// The ORB manager.
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
77 /// object with it.
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.
88 int init_IR (void);
90 /// Get the reference to the server naming context and the first
91 /// server IOR.
92 int get_first_IOR (void);
94 /// Iterate over the given server context to get the rest of the
95 /// server IORs.
96 int next_n_IORs (CosNaming::BindingIterator_var iter,
97 CosNaming::NamingContext_var server_context);
99 /**
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_;
116 /// My orb.
117 CORBA::ORB_var orb_;
119 /// Clerk seeks time periodically after this interval in secs. from the
120 /// servers in the network.
121 int timer_value_ ;
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.
130 IORS server_;
132 /// Read IORs from a file.
133 int ior_fp_;
136 #endif /* CLERK_I_H */