Required flexibility: perform different configurations on your application at runtime to use different services. The ACE service configurator framework is an implementation of the component configurator mode. Configure static services A static service is a service where code is linked to executable programs. Core: 1. Your service class must beAce_service_object. 2. Each Service must implement the following hook methods: Virtual int Init (INT argc, ace_tchar * argv [])The framework will call this method when the service instance is initialized. Virtual int Fini (void)The framework will call this method when the service instance is closed. Virtual int Info (ace_tchar ** STR, size_t Len)(Optional) The Service uses this method to report information about itself.Ace stores known and configurable static services in an internal repository. Every static service must use some macros provided by Ace to insert some note information into this repository. Put in the. cpp file of the service. Initialize service step 3 Ace_factory_define (CLS, service_class) Help create and destroy objects CLS: Your program/library is used to import/export the Declaration identifier. If you do not need to export to DLL, you can useAce_local_service Service_class: slaveThe name of the class derived from ace_service_object is instantiated during service initialization.
Ace_static_svc_define (service_var, name, type, factory, flags, active) Register all required information from the warehouse Service_var: name of the created static object Name: a text string. This name will be used in the service configuration file to identify the service. It should not contain spaces. Type: Type of the object being registered.Ace_svc_obj_t. Factory: A pointer pointing to the factory function used to create a service object instance. GenerallyAce_svc_name (service_class). Flags: Specifies how to handle service-related objects when the service is closed. UseCommonAce_service_type: delete_this | ace_service_type: delete_obj Active: 1 indicates activation after the program starts. 0 indicates that initialization is performed according to the commands in the configuration file.
Ace_static_svc_require (service_var) Make sure that you create an instance of your service object when your program starts and register it with the Framework. Service_var: name of the created static object The format of the static service configuration line: Static service-name [arguments] Start the service Ace_static_svc_register (ha_status_descriptor); // ha_status_descriptor creates a static object name Ace_service_config: open (argc, Argv, Ace_default_logger_key, 0 ); Ace_service_config: open () by default, files named SVC. conf in the current directory are processed. Set dynamic services Dynamic services can be dynamically loaded from the shared library (DLL. Differences from static services: 1) the dynamic service class will reside in the shared library (DLL), so when the service class is declared (Class derived from ace_service_object) The appropriate export declaration must be used. 2) Only the required macros:Ace_factory_define |