Skip to main content
summaryrefslogtreecommitdiffstats
blob: 52d876b17ef340e7468e0f42e0c716015df926a7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*******************************************************************************
 * 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;
	}

	virtual void initialize(void);
	virtual void setProbesActive(bool recursive, bool active) {}

	//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_ */

Back to the top