blob: 7bd002ca94433b6aa5de6e615e6cdbe61d0fc1b4 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* CONTRIBUTORS:
* Peter Karlitschek (initial contribution)
*
*******************************************************************************/
#ifndef ACTORCLASSBASE_H_
#define ACTORCLASSBASE_H_
#include "common/messaging/Address.h"
#include "common/messaging/IMessageReceiver.h"
#include "common/modelbase/RTSystemProtocol.h"
#include "common/modelbase/SystemPortOwner.h"
#include "etDatatypes.h"
#include <string>
namespace etRuntime {
class ActorClassBase: public SystemPortOwner, public virtual IMessageReceiver {
public:
virtual ~ActorClassBase();
const std::string& getClassName() const {
return m_className;
}
void setClassName(const std::string& className) {
m_className = className;
}
virtual const Address& getAddress() const {
// TODO: Actor should have its own address for services and debugging
return Address::EMPTY;
}
//SubSystemClassBase* getSubSystem() const;
//--------------------- lifecycle functions
// automatically generated lifecycle functions
virtual void init();
virtual void start();
virtual void stop();
virtual void destroy();
virtual void executeInitTransition() = 0;
// not automatically generated lifecycle functions
// are called, but with empty implementation -> can be overridden by user
virtual void initUser() {
}
virtual void startUser() {
}
virtual void stopUser() {
}
virtual void receive(const Message* msg) {
}
int getState() const {
return m_state;
}
protected:
ActorClassBase(IRTObject* parent, const std::string&);
static const int EVT_SHIFT = 1000; // TODOHRR: use 256 or shift operation later
static const int NO_STATE = 0;
static const int STATE_TOP = 1;
static const int NOT_CAUGHT = 0;
static const int IFITEM_RTSystemPort = 0;
/**
* the current state
*/
int m_state;
RTSystemPort m_RTSystemPort;
virtual etBool handleSystemEvent(InterfaceItemBase* ifitem, int evt, void* generic_data);
std::string toString() const;
private:
std::string m_className;
ActorClassBase();
ActorClassBase(ActorClassBase const&);
ActorClassBase& operator=(ActorClassBase const&);
};
} /* namespace etRuntime */
#endif /* ACTORCLASSBASE_H_ */