Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / examples / AMH / Sink_Server / Base_Server.h
blobc6ea1f7465437868522c3aa581e6f56796ec8d0d
1 // -*- C++ -*-
3 // =========================================================================
4 /**
5 * @file Base_Server.h
7 * @desc Implements common CORBA server ORB and POA initialisations.
9 * @author Mayur Deshpande <mayur@ics.uci.edu>
11 // =========================================================================
14 #ifndef BASE_SERVER_H
15 #define BASE_SERVER_H
17 #include /**/ "ace/pre.h"
19 #include "tao/PortableServer/PortableServer.h"
20 #include "tao/PortableServer/Servant_Base.h"
22 #include "tao/ORB.h"
24 // Forward declaration of the kind of servant we are willing to handle
25 // in this server
26 class AMH_Servant;
28 /**
29 Class that performs all 'dirty' initialisation work that is common to
30 all the AMH servers and 'hides' all the common ORB functions.
32 class Base_Server
34 public:
35 Base_Server (int &argc, ACE_TCHAR **argv);
37 // Is there any reason to make the destructor virtual? Will you
38 // ever be destroying a derived class through a pointer to
39 // Base_Server?
41 // Mayur: I like to code 'defensively': This class already has
42 // virtual methods (it is a base class after all!). Making the
43 // destructor won't add any additional overhead (other than one more
44 // entry in the vtbl) and if, by chance, someone does delete a
45 // derived-class though this classes ptr, we are still safe. The
46 // short answer to your question is : I don't know. :)
47 virtual ~Base_Server (void);
49 // Just parse the command line for the output-file (-o) option.
50 // return -1 if -o option is not present
51 virtual int parse_args (void);
53 /// try and schedule using FIFO
54 void try_RT_scheduling (void);
56 /// ORB inititalisation stuff
57 int start_orb_and_poa (void);
59 int shutdown_orb_and_poa (void);
61 /// register the servant with the poa
62 virtual void register_servant (AMH_Servant *servant);
64 /// orb-perform_work () abstraction
65 virtual void run_event_loop (void);
67 public:
68 // @@ Mayur, please put inlined methods in a separate `.inl' file,
69 // as detailed in the ACE/TAO coding/style guidelines, and as per
70 // our conventions.
71 // Mayur: A separate file for just one method? AAAGH. OK.
73 /// Accesor method (for servants) to the initialised ORB
74 CORBA::ORB_ptr orb (void);
76 protected:
77 int &argc_;
78 ACE_TCHAR **argv_;
79 const ACE_TCHAR *ior_output_file_;
80 CORBA::ORB_var orb_;
81 PortableServer::POA_var root_poa_;
83 private:
84 /// Write servant IOR to file specified with the '-o' option
85 int write_ior_to_file (const char * ior);
88 #if defined (__ACE_INLINE__)
89 # include "Base_Server.inl"
90 #endif /* __ACE_INLINE__ */
92 #include /**/ "ace/post.h"
93 #endif /* BASE_SERVER_H */