softwarecontainer
0.18.0-739e8d7 2017-05-04
|
Gateway base class for SoftwareContainer. More...
#include <gateway.h>
Public Types | |
enum | GatewayState : unsigned int { CREATED, CONFIGURED, ACTIVATED } |
Public Member Functions | |
Gateway (const std::string &id, std::shared_ptr< ContainerAbstractInterface > container, bool isDynamic=false) | |
Constructor for inheriting classes to initilize. More... | |
virtual std::string | id () const |
Returns the ID of the gateway. More... | |
virtual bool | setConfig (const json_t *config) |
Configure this gateway according to the supplied JSON configuration string. More... | |
virtual bool | activate () |
Applies any configuration set by setConfig() More... | |
virtual bool | teardown () |
Restore system to the state prior to launching of gateway. More... | |
virtual bool | isConfigured () |
Is the gateway configured or not? More... | |
virtual bool | isActivated () |
Is the gateway activated or not? More... | |
Protected Member Functions | |
virtual bool | readConfigElement (const json_t *element)=0 |
Gateway specific parsing of config elements. More... | |
std::shared_ptr< ContainerAbstractInterface > | getContainer () |
Get a handle to the associated container. More... | |
bool | setEnvironmentVariable (const std::string &variable, const std::string &value) |
Set an environment variable in the associated container. More... | |
virtual bool | activateGateway ()=0 |
virtual bool | teardownGateway ()=0 |
Protected Attributes | |
bool | m_activatedOnce |
Gateway base class for SoftwareContainer.
Gateways can be in one of three states:
The complete gateway config is passed as a JSON array and all gateways then provide their specific parsing of the items in the array.
Gateways can specify if they are 'dynamic' or not when initializing this base class. A dynamic gateway supports multiple calls to setConfig and activate.
softwarecontainer::Gateway::Gateway | ( | const std::string & | id, |
std::shared_ptr< ContainerAbstractInterface > | container, | ||
bool | isDynamic = false |
||
) |
Constructor for inheriting classes to initilize.
Gateways that supports quick-launch should flag for this when initializing this base class.
id | Specific gateway ID used to match with configurations. |
container | An interface to the Container that this gateway is part of. |
isDynamic | Set to 'true' to indicate the inheriting class supports re-configuration and re-activation |
Definition at line 25 of file gateway.cpp.
|
virtual |
Returns the ID of the gateway.
Definition at line 36 of file gateway.cpp.
Referenced by activate(), softwarecontainer::DBusGatewayInstance::DBusGatewayInstance(), setConfig(), and teardown().
|
virtual |
Configure this gateway according to the supplied JSON configuration string.
config | JSON string containing gateway-specific JSON configuration |
config
was successfully parsed, false otherwiseGatewayError | If called on an already activated gateway. |
Reimplemented in softwarecontainer::DBusGateway.
Definition at line 41 of file gateway.cpp.
References id(), and readConfigElement().
|
virtual |
Applies any configuration set by setConfig()
GatewayError | If called on an already activated gateway, or if the gateway has not been previously configured, or if there is not container instance set. |
Reimplemented in softwarecontainer::DBusGateway.
Definition at line 78 of file gateway.cpp.
References id().
|
virtual |
Restore system to the state prior to launching of gateway.
Any cleanup code (removal of files, virtual interfaces, etc) should be placed here.
GatewayError | If called on a non activated gateway. |
Reimplemented in softwarecontainer::DBusGateway.
Definition at line 103 of file gateway.cpp.
References id().
Referenced by softwarecontainer::DBusGatewayInstance::DBusGatewayInstance().
|
virtual |
Is the gateway configured or not?
Reimplemented in softwarecontainer::DBusGateway.
Definition at line 134 of file gateway.cpp.
|
virtual |
Is the gateway activated or not?
Dynamic gateways will return true if they have been activated at least once. Non-dynamic gateways will return true if they are in state ACTIVATED
Reimplemented in softwarecontainer::DBusGateway.
Definition at line 139 of file gateway.cpp.
Referenced by softwarecontainer::DBusGatewayInstance::DBusGatewayInstance().
|
protectedpure virtual |
Gateway specific parsing of config elements.
All gateways implement this method in order to provide gateway specific parsing of the configuration content.
element | A JSON configuration item. |
Implemented in softwarecontainer::NetworkGateway, softwarecontainer::DeviceNodeGateway, softwarecontainer::DBusGatewayInstance, softwarecontainer::DBusGateway, softwarecontainer::FileGateway, softwarecontainer::CgroupsGateway, softwarecontainer::PulseGateway, softwarecontainer::WaylandGateway, and softwarecontainer::EnvironmentGateway.
Referenced by setConfig().
|
protected |
Get a handle to the associated container.
GatewayError | If called before setContainer() has been called. |
Definition at line 128 of file gateway.cpp.
Referenced by softwarecontainer::NetworkGateway::activateGateway(), softwarecontainer::DBusGatewayInstance::activateGateway(), softwarecontainer::WaylandGateway::readConfigElement(), and softwarecontainer::NetworkGateway::teardownGateway().
|
protected |
Set an environment variable in the associated container.