CppMicroServices

C++ Micro Services: Framework Class Reference
Framework Class Reference

The CppMicroServices Framework. More...

Inheritance diagram for Framework:
Collaboration diagram for Framework:

Public Member Functions

virtual ~Framework (void)
 
void Start ()
 Start this Framework. More...
 
void Stop ()
 Stop this Framework. More...
 
void Uninstall ()
 The Framework cannot be uninstalled. More...
 
std::string GetLocation () const
 Returns this Framework's location. More...
 
void SetAutoLoadingEnabled (bool enable)
 Enable or disable auto-install support. More...
 
- Public Member Functions inherited from Module
 Module (const Module &)=delete
 
Moduleoperator= (const Module &)=delete
 
virtual ~Module ()
 
bool IsLoaded () const
 Returns this module's current state. More...
 
ModuleContextGetModuleContext () const
 Returns this module's ModuleContext. More...
 
long GetModuleId () const
 Returns this module's unique identifier. More...
 
std::string GetName () const
 Returns the name of this module as specified by the US_CREATE_MODULE CMake macro. More...
 
ModuleVersion GetVersion () const
 Returns the version of this module as specified by the US_INITIALIZE_MODULE CMake macro. More...
 
Any GetProperty (const std::string &key) const
 Returns the value of the specified property for this module. More...
 
std::vector< std::string > GetPropertyKeys () const
 Returns a list of top-level property keys for this module. More...
 
std::vector< ServiceReferenceUGetRegisteredServices () const
 Returns this module's ServiceReference list for all services it has registered or an empty list if this module has no registered services. More...
 
std::vector< ServiceReferenceUGetServicesInUse () const
 Returns this module's ServiceReference list for all services it is using or returns an empty list if this module is not using any services. More...
 
ModuleResource GetResource (const std::string &path) const
 Returns the resource at the specified path in this module. More...
 
std::vector< ModuleResourceFindResources (const std::string &path, const std::string &filePattern, bool recurse) const
 Returns resources in this module. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Module
static const std::string & PROP_ID ()
 Returns the property key for looking up this module's id. More...
 
static const std::string & PROP_NAME ()
 Returns the property key for looking up this module's name. More...
 
static const std::string & PROP_LOCATION ()
 Returns the property key for looking up this module's location in the file system. More...
 
static const std::string & PROP_VERSION ()
 Returns the property key with a value of module.version for looking up this module's version identifier. More...
 
static const std::string & PROP_VENDOR ()
 Returns the property key with a value of module.vendor for looking up this module's vendor information. More...
 
static const std::string & PROP_DESCRIPTION ()
 Returns the property key with a value of module.description for looking up this module's description. More...
 
static const std::string & PROP_AUTOLOAD_DIR ()
 Returns the property key with a value of module.autoload_dir for looking up this module's auto-load directory. More...
 
static const std::string & PROP_AUTOLOADED_MODULES ()
 Returns the property key with a value of module.autoloaded_modules for looking up this module's auto-load modules. More...
 

Detailed Description

The CppMicroServices Framework.

A Framework is itself a bundle and is known as the "System Bundle". The System Bundle differs from other bundles in the following ways:

  • The system bundle is always assigned a bundle identifier of zero (0).
  • The system bundle GetLocation method returns the string: "System Bundle".
  • The system bundle's life cycle cannot be managed like normal bundles. Its life cycle methods must behave as follows:
    • Start - Does nothing because the system bundle is already started.
    • Stop - Stops all installed bundles.
    • Uninstall - The Framework must throw a std::runtime_error exception indicating that the system bundle cannot be uninstalled.

Framework instances are created using a FrameworkFactory. The methods of this class can be used to manage and control the created framework instance.

Remarks
This class is thread-safe.
See also
FrameworkFactory::NewFramework(std::map<std::string, std::string> configuration)

Constructor & Destructor Documentation

virtual Framework::~Framework ( void  )
virtual

Member Function Documentation

std::string Framework::GetLocation ( ) const
virtual

Returns this Framework's location.

This Framework is assigned the unique location "System Bundle" since this Framework is also a System Bundle.

Returns
The string "System Bundle".

Reimplemented from Module.

void Framework::SetAutoLoadingEnabled ( bool  enable)

Enable or disable auto-install support.

Parameters
enableIf true, enable auto-install support, disable it otherwise.
Remarks
Calling this method will have no effect if support for auto-loading has not been configured into the CppMicroServices library or if it has been disabled by defining the US_DISABLE_AUTOLOADING envrionment variable.
Deprecated:
This method remains for legacy clients and will be removed in a future release. Auto-loading support will be moved into a seprate service, at which point, this method will be permanently removed.
void Framework::Start ( )
virtual

Start this Framework.

The following steps are taken to start this Framework:

  1. If this Framework is not in the STARTING state, start this Framework.
  2. This Framework's state is set to ACTIVE.
Exceptions
std::runtime_errorIf this Framework could not be started.

Reimplemented from Module.

void Framework::Stop ( )
virtual

Stop this Framework.

The following steps are taken to stop this Framework:

  1. This Framework's state is set to STOPPING.
  2. All installed bundles must be stopped.
  3. Unregister all services registered by this Framework.
  4. Event handling is disabled.
  5. All resources held by this Framework are released. This includes threads, open files, etc.

After being stopped, this Framework may be discarded or started.

Exceptions
std::runtime_errorIf stopping this Framework could not be initiated.

Reimplemented from Module.

void Framework::Uninstall ( )
virtual

The Framework cannot be uninstalled.

This method always throws a std::runtime_error exception.

Exceptions
std::runtime_errorThis Framework cannot be uninstalled.

Reimplemented from Module.