Download User`s Manual

Transcript
Common Services Framework User’s Manual
#include <stdlib.h>
#include <time.h>
#include <try/memory>
using
using
using
using
using
namespace atst::cs::interfaces;
namespace atst::cs::data;
namespace atst::cs::util;
namespace atst::cs::services;
std::tr1::shared_ptr;
//header file
class ExampleController;
class PostingThread : public atst::cs::util::threads::Runnable {
public:
PostingThread(ExampleController* parent);
void doRun();
void stop();
private:
ExampleController* controller;
bool stopFlag;
};
class ExampleController : public Controller {
public:
int getState();
protected:
pActionResponse doSubmit(pIConfiguration configuration);
bool doAbort(const std::string& configId);
bool doCancel(const std::string& configId);
bool doPause(const std::string& configId);
bool doResume(const std::string& configId);
void doInit() throw(LifeCycleChangeException);
void doStartup() throw(LifeCycleChangeException);
pActionResponse doAction(shared_ptr<IConfiguration> config);
pActionResponse doCanRun(shared_ptr<IConfiguration> config);
void doShutdown() throw(LifeCycleChangeException);
//void doUninit() throw(LifeCycleChangeException);
//void doRemove() throw(LifeCycleChangeException);
pIAttributeTable doGet(pIAttributeTable table);
void doSet(pIAttributeTable table);
int calcDelay(pIConfiguration config);
private:
int state;
shared_ptr<PostingThread> pt;
static const int UNKNOWN_STATE;
static const int AT_REST_STATE;
};
//source file
const int ExampleController::AT_REST_STATE = 0;
const int ExampleController::UNKNOWN_STATE = -1;
pActionResponse ExampleController::doSubmit(pIConfiguration config) {
// if we get here we know that the technical architecture has
SPEC-0022-1, Rev I
Page 100 of 106