Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 8e6390d1a5c1d4c8100995c4c7428664bd3a12b6 (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
103
/*******************************************************************************
 * 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 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * 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"

namespace etRuntime {


class ActorClassBase: public SystemPortOwner, public virtual IMessageReceiver {
public:

	virtual ~ActorClassBase();

	const String& getClassName() const {
		return m_className;
	}

	void setClassName(const 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 String& name);

	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);
	String toString() const;
private:
	String m_className;

	ActorClassBase();
	ActorClassBase(ActorClassBase const&);
	ActorClassBase& operator=(ActorClassBase const&);

};

} /* namespace etRuntime */
#endif /* ACTORCLASSBASE_H_ */

Back to the top