3 //=============================================================================
7 * Declares a generic object that acts as "main" for a CORBA server.
8 * @author Dale Wilson <wilson_d@ociweb.com>
10 * This object supports creation of a relatively simple CORBA server.
11 * The object implements "main" for a process.
12 * A single servant is created and initialized as the process begins
13 * execution. The lifetime of this initial servant is the lifetime of
15 * The servant is free to create other servants as necessary.
16 * The servant can capture command line options.
17 * A callback method in the ORB event loop allows the servant to act
18 * asynchronously if necessary.
19 * The callback method allows the servant to request process termination
20 * and specify the status to be returned from the process.
22 * The application should create a C/C++ main that looks something like:
23 * #include <tao/Utils/Server_Main.h>
24 * #include "Xyzzy_i.h"
25 * int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
27 * Server_Main<Xyzzy_i> servant ("Xyzzy");
28 * return servant.run(argc, argv);
31 * The servant implementation (Xyzzy_i in this case) must implement
32 * the following methods:
33 * Xyzzy_i (); // null constructor
34 * ~Xyzzy_i (); // destructor
35 * int parse_args (int argc, ACE_TCHAR * argv[]);
36 * int init (CORBA::ORB_ptr orb );
37 * int idle(int &result);
39 * const char * identity () const;
41 * parse_args, self_register, self_unregister return 0 if ok, nonzero for error.
42 * idle returns 0 to continue execution; nonzero to exit -- returning "result" from the process
43 * identity provides a string to identify this servant in log messages.
45 //=============================================================================
47 #ifndef TAO_UTILS_SERVANTMAIN_H
48 #define TAO_UTILS_SERVANTMAIN_H
50 #include /**/ "ace/pre.h"
54 #if !defined (ACE_LACKS_PRAGMA_ONCE)
56 #endif /* ACE_LACKS_PRAGMA_ONCE */
58 #include "tao/orbconf.h"
59 #include "ace/Copy_Disabled.h"
61 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
67 template <typename SERVANT
>
68 class Server_Main
: private ACE_Copy_Disabled
71 Server_Main(const char * name
);
74 int run (int argc
, ACE_TCHAR
*argv
[]);
82 TAO_END_VERSIONED_NAMESPACE_DECL
84 #include "tao/Utils/Server_Main.cpp"
86 #include /**/ "ace/post.h"
88 #endif //TAO_UTILS_SERVANTMAIN_H