#include <ace/Service_Config.h>
class ACE_Service_Config {
public:
enum{ MAX_SERVICES = ACE_DEFAULT_SERVICE_REPOSITORY_SIZE };
ACE_Service_Config ( int ignore_static_svcs = 1, size_t size = ACE_Service_Config::MAX_SERVICES, int signum = SIGHUP );
ACE_Service_Config ( const ASYS_TCHAR program_name[], LPCTSTR logger_key = ACE_DEFAULT_LOGGER_KEY );
static int open_i ( const ASYS_TCHAR program_name[], LPCTSTR logger_key = ACE_DEFAULT_LOGGER_KEY, int ignore_default_svc_conf_file = 0, int ignore_debug_flag = 0 );
static int open ( const ASYS_TCHAR program_name[], LPCTSTR logger_key = ACE_DEFAULT_LOGGER_KEY, int ignore_static_svcs = 1, int ignore_default_svc_conf_file = 0, int ignore_debug_flag = 0 );
static int open ( int argc, ASYS_TCHAR *argv[], LPCTSTR logger_key = ACE_DEFAULT_LOGGER_KEY, int ignore_static_svcs = 1, int ignore_default_svc_conf = 0, int ignore_debug_flag = 0 );
virtual ~ACE_Service_Config (void);
static int close (void);
static int fini_svcs (void);
static int close_svcs (void);
static int close_singletons (void);
static int run_reactor_event_loop (void);
static int run_reactor_event_loop (ACE_Time_Value &tv);
static int end_reactor_event_loop (void);
static int reactor_event_loop_done (void);
static int reconfig_occurred (void);
static void reconfig_occurred (int);
static void reconfigure (void);
static ACE_STATIC_SVCS *static_svcs (void);
static ACE_Reactor *reactor (void);
static ACE_Reactor *reactor (ACE_Reactor *);
static ACE_Service_Repository *svc_rep (void);
static ACE_Service_Repository *svc_rep (ACE_Service_Repository *);
static ACE_Thread_Manager *thr_mgr (void);
static ACE_Thread_Manager *thr_mgr (ACE_Thread_Manager *);
static ACE_Allocator *alloc (void);
static ACE_Allocator *alloc (ACE_Allocator *);
static int initialize ( const ACE_Service_Type *, ASYS_TCHAR parameters[] );
static int initialize ( const ASYS_TCHAR svc_name[], ASYS_TCHAR parameters[] );
static int resume (const ASYS_TCHAR svc_name[]);
static int suspend (const ASYS_TCHAR svc_name[]);
static int remove (const ASYS_TCHAR svc_name[]);
static int initialize ( const ACE_Service_Type *, char parameters[] );
static int initialize (const char svc_name[], char parameters[]);
static int resume (const char svc_name[]);
static int suspend (const char svc_name[]);
static int remove (const char svc_name[]);
void dump (void) const;
static ACE_INLINE void signal_handler (ACE_Sig_Adapter *);
ACE_ALLOC_HOOK_DECLARE;
static int process_directive (const ASYS_TCHAR directive[]);
static int process_directives (void);
static void handle_signal (int sig, siginfo_t *, ucontext_t *);
protected:
static int process_commandline_directives (void);
static int process_directives_i (void);
static int parse_args (int, ASYS_TCHAR *argv[]);
static int start_daemon (void);
static int load_static_svcs (void);
private:
static LPCTSTR logger_key_;
static ACE_STATIC_SVCS *static_svcs_;
static ACE_SVC_QUEUE *svc_queue_;
static ACE_SVC_QUEUE *svc_conf_file_queue_;
static int init_svc_conf_file_queue (void);
static sig_atomic_t reconfig_occurred_;
static char be_a_daemon_;
static char no_static_svcs_;
static int signum_;
static ACE_Sig_Adapter *signal_handler_;
static int is_initialized_;
};
ACE_Service_Config
uses the Monostate pattern. Therefore,
you can only have one of these instantiated per-process.
NOTE: the signal_handler_ static member is allocated by the
ACE_Object_Manager
. The ACE_Service_Config
constructor
uses signal_handler_. Therefore, if the program has any
static ACE_Service_Config
objects, there might be
initialization order problems. They can be minimized, but
not eliminated, by _not_ #defining
ACE_HAS_NONSTATIC_OBJECT_MANAGER
.
ACE_Service_Config (
int ignore_static_svcs = 1,
size_t size = ACE_Service_Config::MAX_SERVICES,
int signum = SIGHUP
);
ACE_Service_Config (
const ASYS_TCHAR program_name[],
LPCTSTR logger_key = ACE_DEFAULT_LOGGER_KEY
);
logger_key
indicates where to write the logging output, which
is typically either a STREAM pipe or a socket address.
static int open_i (
const ASYS_TCHAR program_name[],
LPCTSTR logger_key = ACE_DEFAULT_LOGGER_KEY,
int ignore_default_svc_conf_file = 0,
int ignore_debug_flag = 0
);
logger_key
indicates where to write the logging output, which
is typically either a STREAM pipe or a socket address. If
ignore_default_svc_conf_file
is non-0 then the "svc.conf" file
will be ignored. If ignore_debug_flag
is non-0 then the
application is responsible for setting the
ACE_Log_Msg::priority_mask
appropriately. Returns number of
errors that occurred on failure and 0 otherwise.
static int open (
const ASYS_TCHAR program_name[],
LPCTSTR logger_key = ACE_DEFAULT_LOGGER_KEY,
int ignore_static_svcs = 1,
int ignore_default_svc_conf_file = 0,
int ignore_debug_flag = 0
);
logger_key
indicates where to write the logging output, which
is typically either a STREAM pipe or a socket address. If
ignore_static_svcs
is 1 then static services are not loaded,
otherwise, they are loaded. If ignore_default_svc_conf_file
is
non-0 then the svc.conf
configuration file will be ignored.
Returns zero upon success, -1 if the file is not found or cannot
be opened (errno is set accordingly), otherwise returns the
number of errors encountered loading the services in the
specified svc.conf configuration file. If ignore_debug_flag
is
non-0 then the application is responsible for setting the
ACE_Log_Msg::priority_mask
appropriately.
static int open (
int argc,
ASYS_TCHAR *argv[],
LPCTSTR logger_key = ACE_DEFAULT_LOGGER_KEY,
int ignore_static_svcs = 1,
int ignore_default_svc_conf = 0,
int ignore_debug_flag = 0
);
argc
and argv
parameters. The
arguments that are valid in a call to this method include:
'-b' - Option to indicate that we should be a daemon
'-d' - Turn on debugging mode
'-f' - Option to read in the list of svc.conf file names
'-k' - Option to read a wide string where in the logger output can
be written
'-y' - Option required to use statically linked services.
A static service repostory will be constructed if the flag
is used. Use this flag to override the default
ignore_static_svcs
flag at run-time.
'-n' - Option to avoid using any statically linked services, which
eliminates the need to construct the static service repository.
'-S' - Option to read in the list of services on the command-line
Please observe the difference between options '-f' that looks
for a list of files and here a list of services.
Returns number of errors that occurred on failure and 0 otherwise.
The logger_key
indicates where to write the logging output,
which is typically either a STREAM pipe or a socket address. If
ignore_static_svcs
is 1 then static services are not loaded,
otherwise, they are loaded. If ignore_default_svc_conf_file
is
non-0 then the svc.conf
configuration file will be ignored.
Returns zero upon success, -1 if the file is not found or cannot
be opened (errno is set accordingly), otherwise returns the
number of errors encountered loading the services in the
specified svc.conf configuration file. If ignore_debug_flag
is
non-0 then the application is responsible for setting the
ACE_Log_Msg::priority_mask
appropriately.
virtual ~ACE_Service_Config (void);
static int close (void);
close_svcs
. Returns 0.
static int fini_svcs (void);
Service_Repository
.
static int close_svcs (void);
Service_Repository
, then delete the
Service_Repository
itself. Returns 0.
static int close_singletons (void);
Reactor
,
Proactor
, ReactorEx
, and Thread_Manager
.
Returns 0.
static int run_reactor_event_loop (void);
ACE_Reactor::handle_events
method
returns -1 or the end_reactor_event_loop
method is invoked.
DO NOT USE THIS METHOD. It may be unsupported in future releases.
Use ACE_Reactor::run_event_loop
instead.
static int run_reactor_event_loop (ACE_Time_Value &tv);
ACE_Reactor::handle_events
method
returns -1, the end_reactor_event_loop
method is invoked, or the
ACE_Time_Value
expires.
DO NOT USE THIS METHOD. It may be unsupported in future releases.
Use ACE_Reactor::run_event_loop
instead.
static int end_reactor_event_loop (void);
ACE_Service_Config
to terminate its event loop and
notifies the ACE_Reactor::instance
so that it can wake up
and close down gracefully.
DO NOT USE THIS METHOD. It may be unsupported in future releases.
Use ACE_Reactor::end_event_loop
instead.
static int reactor_event_loop_done (void);
ACE_Reactor::event_loop_done
instead.
static int reconfig_occurred (void);
static void reconfig_occurred (int);
static void reconfigure (void);
static ACE_STATIC_SVCS *static_svcs (void);
static ACE_Reactor *reactor (void);
ACE_Reactor
.
DO NOT USE THIS METHOD. It may be unsupported in future releases.
Use ACE_Reactor::instance
instead.
static ACE_Reactor *reactor (ACE_Reactor *);
ACE_Reactor
and return existing
pointer.
DO NOT USE THIS METHOD. It may be unsupported in future releases.
Use ACE_Reactor::instance
instead.
static ACE_Service_Repository *svc_rep (void);
ACE_Service_Repository
.
DO NOT USE THIS METHOD. It may be unsupported in future releases.
Use ACE_Service_Repository::instance
instead.
static ACE_Service_Repository *svc_rep (ACE_Service_Repository *);
ACE_Service_Repository
and return
existing pointer.
DO NOT USE THIS METHOD. It may be unsupported in future releases.
Use ACE_Service_Repository::instance
instead.
static ACE_Thread_Manager *thr_mgr (void);
ACE_Thread_Manager
.
DO NOT USE THIS METHOD. It may be unsupported in future releases.
Use ACE_Thread_Manager::instance
instead.
static ACE_Thread_Manager *thr_mgr (ACE_Thread_Manager *);
ACE_Thread_Manager
and return
existing pointer.
DO NOT USE THIS METHOD. It may be unsupported in future releases.
Use ACE_Thread_Manager::instance() instead.
static ACE_Allocator *alloc (void);
ACE_Allocator
.
DO NOT USE THIS METHOD. It may be unsupported in future releases.
Use ACE_Allocator::instance
instead.
static ACE_Allocator *alloc (ACE_Allocator *);
ACE_Allocator
and return existing
pointer.
DO NOT USE THIS METHOD. It may be unsupported in future releases.
Use ACE_Allocator::instance
instead.
static int initialize (
const ACE_Service_Type *,
ASYS_TCHAR parameters[]
);
static int initialize (
const ASYS_TCHAR svc_name[],
ASYS_TCHAR parameters[]
);
svc_name
service.
static int resume (const ASYS_TCHAR svc_name[]);
svc_name
that was previously suspended or has not yet
been resumed (e.g., a static service).
static int suspend (const ASYS_TCHAR svc_name[]);
svc_name
. Note that this will not unlink the service
from the daemon if it was dynamically linked, it will mark it as
being suspended in the Service Repository and call the suspend
member function on the appropriate ACE_Service_Object
. A
service can be resumed later on by calling the RESUME
member
function...
static int remove (const ASYS_TCHAR svc_name[]);
svc_name
from the daemon by removing it
from the ACE_Reactor, and unlinking it if necessary.
We must provide these function to bridge the Svc_Conf
parser
with ACE.
static int initialize (const ACE_Service_Type *, char parameters[]);
static int initialize (const char svc_name[], char parameters[]);
static int resume (const char svc_name[]);
static int suspend (const char svc_name[]);
static int remove (const char svc_name[]);
void dump (void) const;
static ACE_INLINE void signal_handler (ACE_Sig_Adapter *);
ACE_ALLOC_HOOK_DECLARE;
static int process_directive (const ASYS_TCHAR directive[]);
directive
, which is passed as
a string. Returns the number of errors that occurred.
static int process_directives (void);
static void handle_signal (int sig, siginfo_t *, ucontext_t *);
static char be_a_daemon_;
static char no_static_svcs_;
static int signum_;
static ACE_Sig_Adapter *signal_handler_;
static int is_initialized_;
ACE_Service_Config
is already
initialized. If so, we can't allow yyparse
to be called since
it's not reentrant. This variable is incremented by the
ACE_Service_Config::open
method and decremented by the
ACE_Service_Config::close
method.