ApparatusFramework::StartupHandler Class Reference
[Pattern Services]

#include <PatternServices/current/include/StartupHandler.h>

List of all members.

Classes

struct  Component
struct  ErrorInfo

Public Types

enum  State {
  Registring, Creating, Created, Initializing,
  Initialized, StartingUp, StartedUp, ShuttingDown,
  CleaningUp, Error
}

Static Public Member Functions

static void Register (ComponentCreateFp createFunction, void *argument=0)
static bool Create ()
static bool Initialize ()
static bool Startup ()
static bool Shutdown ()
static bool Cleanup ()
static State getState ()
static const ErrorInfogetError ()

Protected Member Functions

 StartupHandler ()
 ~StartupHandler ()

Detailed Description

The startup handler controls the startup and shutdown of software components. In a first phase, components can register themself with help of the Registrator class. In a second phase, the startup handler creates all the registered components. This is done via a "create" function that has to be provided by the component. The component is free to do whatever it likes in this function, though it is recommended to implement the singleton patter. In a third phase, the components get initialized and in a fourth phase started via the StartupIf. Optionally, components can also implement the shutdown and cleanup phases.

Each phase is further divided into multiple steps (currently 10 steps). This allows detailed control over the sequence in which components are initialized, started, etc. Low level components, such as the EEPROM, that are needed by other components during startup, should do their work in an early step. High level components depending on many others should initialize and start up last.

The startup handler first calles initialize(STEP_0) for all registered components, then initialize(STEP_1) and so on. A component is responsible by itself to do the correct work in the correct step.

If an error is encountered, the startup handler aborts the phase and reports the failure to the client. The client can obtain additional information, such as which component caused the problem and in which step it occured.

All members of the startup handler are static. Clients need not create an instance of this class. Clients can call the functions at any time after static variables and objects have been initialized. The order of calls has to be Create, Initialize, Startup (optionally followed by Shutdown and Cleanup). An error is reported if a client does not stick to this sequence of calls.

Definition at line 102 of file StartupHandler.h.


Member Enumeration Documentation

Defines the possible states of the StartupHandler. Mainly refers to the different phases.

Enumerator:
Registring 
Creating 
Created 
Initializing 
Initialized 
StartingUp 
StartedUp 
ShuttingDown 
CleaningUp 
Error 

Definition at line 175 of file StartupHandler.h.


Constructor & Destructor Documentation

ApparatusFramework::StartupHandler::StartupHandler (  )  [protected]

Construction, Destruction Empty constructor.

ApparatusFramework::StartupHandler::~StartupHandler (  )  [protected]

Empty destructor.


Member Function Documentation

static bool ApparatusFramework::StartupHandler::Cleanup (  )  [static]

Cleans up all registered components step by step. Is the inverse of initialize: internal connections are removed and the component cleans up after itself. This function is seldom used.

Returns:
true if all components are successfully cleaned up, otherwise false. The whole startup process aborts if a component cannot be cleaned up.
static bool ApparatusFramework::StartupHandler::Create (  )  [static]

Creates all registered components by calling their create function passed with the method Register. Components are created in the order in which they register. This usually depends on the linker. It is best not to make any assumptions about the order of creation. Components should therefore not refer to other components in their create function.

Returns:
true if all components are successfully created, otherwise false. The whole startup process aborts if a component cannot be created.
static const ErrorInfo& ApparatusFramework::StartupHandler::getError (  )  [static]

Queries Returns a description of an error, if any.

Returns:
The error information.
static State ApparatusFramework::StartupHandler::getState (  )  [static]

Queries Returns the current State of the StartupHandler.

Returns:
The current State.
static bool ApparatusFramework::StartupHandler::Initialize (  )  [static]

Startup Pattern Initializes all registered components step by step. During initialization, components usually establish connections within the software. E.g. they attach themself as observer to other components. Queries might be done but no actions should be requested. Inputs should remain disabled.

Returns:
true if all components are successfully initialized, otherwise false. The whole startup process aborts if a component cannot be initialized.
static void ApparatusFramework::StartupHandler::Register ( ComponentCreateFp  createFunction,
void *  argument = 0 
) [static]

Creation Registers a component with the startup handler. This method is usually not called by the component directly. Rather, components are registered by making a static instance of the Registrator class.

Parameters:
createFunction Pointer to a function that creates an instance of the registered component. Please refer to class StartupIf.
argument A general purpose argument that will be passed to the create function.
static bool ApparatusFramework::StartupHandler::Shutdown (  )  [static]

Shuts down all registered components step by step. Is the inverse of startup: Communication to peripheral hardware is closed, inputs are disabled and the components switch into disabled mode. After shutdown, a component can be made operational again by calling startup.

Returns:
true if all components are successfully shut down, otherwise false. The whole startup process aborts if a component cannot be shut down
static bool ApparatusFramework::StartupHandler::Startup (  )  [static]

Starts all registered components step by step. During startup, communication to peripheral hardware is established. The components switch to operational mode. Inputs are enabled.

Returns:
true if all components are successfully started, otherwise false. The whole startup process aborts if a component cannot be started.
© 2004-2010 bbv Software Services AG / Apparatus Services