Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2017-01-04 20:07:12 +0000
committerHenrik Rentz-Reichert2017-01-09 16:41:16 +0000
commit9b02d5a62ea41136b46b744f7b2c1cf50f30a888 (patch)
treed7473847da1a9e3a470195f384f62322b48057db /runtime
parentb8fd69cd558c0673971bcdaea495131bc4d7cd82 (diff)
downloadorg.eclipse.etrice-9b02d5a62ea41136b46b744f7b2c1cf50f30a888.tar.gz
org.eclipse.etrice-9b02d5a62ea41136b46b744f7b2c1cf50f30a888.tar.xz
org.eclipse.etrice-9b02d5a62ea41136b46b744f7b2c1cf50f30a888.zip
Bug 509875 - [runtime.cpp] replace STL containers with own containers that are more light weight
* replaced streaming code with (s)printf constructs * added String, Vector, Set, Pair and Map with tests * using new String class in * Address * Message * MSCFilter * MSCLogger * RTObject * and affected classes * using new Vector class in * RTObject * MSCLogger * MessageServiceController * ReplicatedActorClassBase * ReplicatedInterfaceItemBase * and affected classes * using new Set class in * MessageDispatcher * using new Map class in * SubSystemClassBase * DebuggingService * adjusted cpp generator Change-Id: I9c91289057185e6e36b9453ecf03f6f6d3834ec6
Diffstat (limited to 'runtime')
-rw-r--r--runtime/org.eclipse.etrice.modellib.java/jgen_modellib_java.launch2
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src-gen/common/modelbase/RTSystemServicesProtocol.cpp40
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src-gen/common/modelbase/RTSystemServicesProtocol.h20
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Map.cpp20
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Map.h232
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Pair.h84
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Set.cpp20
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Set.h222
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/String.cpp169
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/String.h318
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Vector.cpp22
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Vector.h334
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.cpp61
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.h21
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFilter.cpp10
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFilter.h26
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFunctionObject.cpp12
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFunctionObject.h8
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCLogger.cpp42
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCLogger.h43
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageReceiver.h7
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.cpp5
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.h6
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.cpp3
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.h22
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.cpp19
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.h6
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.cpp20
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.h17
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.cpp2
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.h3
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp10
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.h7
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp26
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h10
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.cpp60
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.h56
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/StaticMessageMemory.cpp7
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/StaticMessageMemory.h2
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp13
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h11
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/DataPort.cpp3
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/DataPort.h9
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.cpp3
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.h3
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.cpp26
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.h7
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.h5
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/RTSystem.h4
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/RTSystemProtocol.cpp13
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/RTSystemProtocol.h7
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedActorClassBase.cpp16
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedActorClassBase.h10
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedInterfaceItemBase.cpp26
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedInterfaceItemBase.h17
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedPortBase.h3
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.cpp44
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.h13
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.cpp18
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.h6
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SystemPortOwner.h3
61 files changed, 1851 insertions, 403 deletions
diff --git a/runtime/org.eclipse.etrice.modellib.java/jgen_modellib_java.launch b/runtime/org.eclipse.etrice.modellib.java/jgen_modellib_java.launch
index fac0a9524..02583c781 100644
--- a/runtime/org.eclipse.etrice.modellib.java/jgen_modellib_java.launch
+++ b/runtime/org.eclipse.etrice.modellib.java/jgen_modellib_java.launch
@@ -6,8 +6,10 @@
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
+<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.etrice.generator.java.Main"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="${workspace_loc:org.eclipse.etrice.modellib.java}/model/ALogService.room&#13;&#10;${workspace_loc:org.eclipse.etrice.modellib.java}/model/TimingService.room&#13;&#10;${workspace_loc:org.eclipse.etrice.modellib.java}/model/TcpService.room&#13;&#10;-lib&#13;&#10;-msc_instr"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.etrice.generator.java"/>
+<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
</launchConfiguration>
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src-gen/common/modelbase/RTSystemServicesProtocol.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src-gen/common/modelbase/RTSystemServicesProtocol.cpp
index 83fa9cd55..77e266e0d 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src-gen/common/modelbase/RTSystemServicesProtocol.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src-gen/common/modelbase/RTSystemServicesProtocol.cpp
@@ -13,22 +13,20 @@
#include "common/messaging/Address.h"
#include "common/messaging/Message.h"
#include "common/modelbase/IEventReceiver.h"
-#include <iterator>
-#include <vector>
using namespace etRuntime;
/* message names as strings for debugging (generate MSC) */
-const std::string RTSystemServicesProtocol::s_messageStrings[] = {"MIN", "executeInitialTransition","startDebugging","stopDebugging","MAX"};
+const String RTSystemServicesProtocol::s_messageStrings[] = {"MIN", "executeInitialTransition","startDebugging","stopDebugging","MAX"};
-const std::string& RTSystemServicesProtocol::getMessageString(int msg_id) {
+const String& RTSystemServicesProtocol::getMessageString(int msg_id) {
if ((MSG_MIN < msg_id ) && ( msg_id < MSG_MAX )) {
return s_messageStrings[msg_id];
} else {
// id out of range
- static const std::string errorMsg = "Message ID out of range";
+ static const String errorMsg = "Message ID out of range";
return errorMsg;
}
}
@@ -37,12 +35,12 @@ const std::string& RTSystemServicesProtocol::getMessageString(int msg_id) {
// port class
//------------------------------------------------------------------------------------------------------------
-RTSystemServicesProtocolPort::RTSystemServicesProtocolPort(IInterfaceItemOwner* actor, const std::string& name, int localId)
+RTSystemServicesProtocolPort::RTSystemServicesProtocolPort(IInterfaceItemOwner* actor, const String& name, int localId)
: PortBase(actor, name, localId, 0)
{
}
-RTSystemServicesProtocolPort::RTSystemServicesProtocolPort(IInterfaceItemOwner* actor, const std::string& name, int localId, int idx)
+RTSystemServicesProtocolPort::RTSystemServicesProtocolPort(IInterfaceItemOwner* actor, const String& name, int localId, int idx)
: PortBase(actor, name, localId, idx)
{
}
@@ -55,10 +53,10 @@ void RTSystemServicesProtocolPort::destroy() {
void RTSystemServicesProtocolPort::receive(const Message* msg) {
// TODO JH further
if (! RTSystemServicesProtocol::isValidIncomingEvtID(msg->getEvtId())) {
- std::cout << "unknown" << std::endl;
+ //std::cout << "unknown" << std::endl;
}
- DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), RTSystemServicesProtocol::getMessageString(msg->getEvtId()));
+ DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), RTSystemServicesProtocol::getMessageString(msg->getEvtId()).c_str());
getActor()->receiveEvent(this, msg->getEvtId(), msg->getData());
}
@@ -69,7 +67,7 @@ void RTSystemServicesProtocolPort::receive(const Message* msg) {
//------------------------------------------------------------------------------------------------------------
// replicated port class
//------------------------------------------------------------------------------------------------------------
-RTSystemServicesProtocolReplPort::RTSystemServicesProtocolReplPort(IInterfaceItemOwner* actor, const std::string& name, int localId) :
+RTSystemServicesProtocolReplPort::RTSystemServicesProtocolReplPort(IInterfaceItemOwner* actor, const String& name, int localId) :
ReplicatedPortBase(actor, name, localId)
{
}
@@ -79,12 +77,12 @@ RTSystemServicesProtocolReplPort::RTSystemServicesProtocolReplPort(IInterfaceIte
// conjugated port class
//------------------------------------------------------------------------------------------------------------
-RTSystemServicesProtocolConjPort::RTSystemServicesProtocolConjPort(IInterfaceItemOwner* actor, const std::string& name, int localId)
+RTSystemServicesProtocolConjPort::RTSystemServicesProtocolConjPort(IInterfaceItemOwner* actor, const String& name, int localId)
: PortBase(actor, name, localId, 0)
{
}
-RTSystemServicesProtocolConjPort::RTSystemServicesProtocolConjPort(IInterfaceItemOwner* actor, const std::string& name, int localId, int idx)
+RTSystemServicesProtocolConjPort::RTSystemServicesProtocolConjPort(IInterfaceItemOwner* actor, const String& name, int localId, int idx)
: PortBase(actor, name, localId, idx)
{
}
@@ -97,10 +95,10 @@ void RTSystemServicesProtocolConjPort::destroy() {
void RTSystemServicesProtocolConjPort::receive(const Message* msg) {
// TODO JH further
if (! RTSystemServicesProtocol::isValidOutgoingEvtID(msg->getEvtId())) {
- std::cout << "unknown" << std::endl;
+ //std::cout << "unknown" << std::endl;
}
- DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), RTSystemServicesProtocol::getMessageString(msg->getEvtId()));
+ DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), RTSystemServicesProtocol::getMessageString(msg->getEvtId()).c_str());
getActor()->receiveEvent(this, msg->getEvtId(), msg->getData());
}
@@ -113,7 +111,7 @@ void RTSystemServicesProtocolConjPort::executeInitialTransition() {
void RTSystemServicesProtocolConjPort::executeInitialTransition_impl() {
DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
- RTSystemServicesProtocol::getMessageString(RTSystemServicesProtocol::IN_executeInitialTransition));
+ RTSystemServicesProtocol::getMessageString(RTSystemServicesProtocol::IN_executeInitialTransition).c_str());
if (getPeerAddress().isValid()) {
Message* buffer = dynamic_cast<IMessageService*>(getPeerMsgReceiver())->getMessageBuffer(sizeof(Message));
if (buffer) {
@@ -127,7 +125,7 @@ void RTSystemServicesProtocolConjPort::startDebugging() {
void RTSystemServicesProtocolConjPort::startDebugging_impl() {
DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
- RTSystemServicesProtocol::getMessageString(RTSystemServicesProtocol::IN_startDebugging));
+ RTSystemServicesProtocol::getMessageString(RTSystemServicesProtocol::IN_startDebugging).c_str());
if (getPeerAddress().isValid()) {
Message* buffer = dynamic_cast<IMessageService*>(getPeerMsgReceiver())->getMessageBuffer(sizeof(Message));
if (buffer) {
@@ -141,7 +139,7 @@ void RTSystemServicesProtocolConjPort::stopDebugging() {
void RTSystemServicesProtocolConjPort::stopDebugging_impl() {
DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
- RTSystemServicesProtocol::getMessageString(RTSystemServicesProtocol::IN_stopDebugging));
+ RTSystemServicesProtocol::getMessageString(RTSystemServicesProtocol::IN_stopDebugging).c_str());
if (getPeerAddress().isValid()) {
Message* buffer = dynamic_cast<IMessageService*>(getPeerMsgReceiver())->getMessageBuffer(sizeof(Message));
if (buffer) {
@@ -153,24 +151,24 @@ void RTSystemServicesProtocolConjPort::stopDebugging_impl() {
//------------------------------------------------------------------------------------------------------------
// conjugated replicated port class
//------------------------------------------------------------------------------------------------------------
-RTSystemServicesProtocolConjReplPort::RTSystemServicesProtocolConjReplPort(IInterfaceItemOwner* actor, const std::string& name, int localId) :
+RTSystemServicesProtocolConjReplPort::RTSystemServicesProtocolConjReplPort(IInterfaceItemOwner* actor, const String& name, int localId) :
ReplicatedPortBase(actor, name, localId)
{
}
// incoming messages
void RTSystemServicesProtocolConjReplPort::executeInitialTransition(){
- for (std::vector<etRuntime::InterfaceItemBase*>::iterator it = getItems().begin(); it != getItems().end(); ++it) {
+ for (Vector<etRuntime::InterfaceItemBase*>::iterator it = getItems().begin(); it != getItems().end(); ++it) {
(dynamic_cast<RTSystemServicesProtocolConjPort*>(*it))->executeInitialTransition();
}
}
void RTSystemServicesProtocolConjReplPort::startDebugging(){
- for (std::vector<etRuntime::InterfaceItemBase*>::iterator it = getItems().begin(); it != getItems().end(); ++it) {
+ for (Vector<etRuntime::InterfaceItemBase*>::iterator it = getItems().begin(); it != getItems().end(); ++it) {
(dynamic_cast<RTSystemServicesProtocolConjPort*>(*it))->startDebugging();
}
}
void RTSystemServicesProtocolConjReplPort::stopDebugging(){
- for (std::vector<etRuntime::InterfaceItemBase*>::iterator it = getItems().begin(); it != getItems().end(); ++it) {
+ for (Vector<etRuntime::InterfaceItemBase*>::iterator it = getItems().begin(); it != getItems().end(); ++it) {
(dynamic_cast<RTSystemServicesProtocolConjPort*>(*it))->stopDebugging();
}
}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src-gen/common/modelbase/RTSystemServicesProtocol.h b/runtime/org.eclipse.etrice.runtime.cpp/src-gen/common/modelbase/RTSystemServicesProtocol.h
index 49f575623..83301edb3 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src-gen/common/modelbase/RTSystemServicesProtocol.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src-gen/common/modelbase/RTSystemServicesProtocol.h
@@ -38,10 +38,10 @@ class RTSystemServicesProtocol {
static bool isValidIncomingEvtID(int evtId) {
return ((IN_executeInitialTransition <= evtId) && (evtId < MSG_MAX));
}
- static const std::string& getMessageString(int msg_id);
+ static const etRuntime::String& getMessageString(int msg_id);
private:
- static const std::string s_messageStrings[];
+ static const etRuntime::String s_messageStrings[];
};
@@ -50,8 +50,8 @@ class RTSystemServicesProtocol {
//------------------------------------------------------------------------------------------------------------
class RTSystemServicesProtocolPort : public etRuntime::PortBase {
public:
- RTSystemServicesProtocolPort(etRuntime::IInterfaceItemOwner* actor, const std::string& name, int localId);
- RTSystemServicesProtocolPort(etRuntime::IInterfaceItemOwner* actor, const std::string& name, int localId, int idx);
+ RTSystemServicesProtocolPort(etRuntime::IInterfaceItemOwner* actor, const etRuntime::String& name, int localId);
+ RTSystemServicesProtocolPort(etRuntime::IInterfaceItemOwner* actor, const etRuntime::String& name, int localId, int idx);
virtual void destroy();
@@ -67,7 +67,7 @@ class RTSystemServicesProtocolPort : public etRuntime::PortBase {
class RTSystemServicesProtocolReplPort : public etRuntime::ReplicatedPortBase {
public:
- RTSystemServicesProtocolReplPort(etRuntime::IInterfaceItemOwner* actor, const std::string& name, int localId);
+ RTSystemServicesProtocolReplPort(etRuntime::IInterfaceItemOwner* actor, const etRuntime::String& name, int localId);
int getReplication() const { return getNInterfaceItems(); }
int getIndexOf(const etRuntime::InterfaceItemBase& ifitem) const { return ifitem.getIdx(); }
@@ -76,7 +76,7 @@ class RTSystemServicesProtocolReplPort : public etRuntime::ReplicatedPortBase {
// outgoing messages
protected:
- virtual etRuntime::InterfaceItemBase* createInterfaceItem(etRuntime::IInterfaceItemOwner* rcv, const std::string& name, int lid, int idx) {
+ virtual etRuntime::InterfaceItemBase* createInterfaceItem(etRuntime::IInterfaceItemOwner* rcv, const etRuntime::String& name, int lid, int idx) {
return new RTSystemServicesProtocolPort(rcv, name, lid, idx);
}
@@ -86,8 +86,8 @@ class RTSystemServicesProtocolReplPort : public etRuntime::ReplicatedPortBase {
//------------------------------------------------------------------------------------------------------------
class RTSystemServicesProtocolConjPort : public etRuntime::PortBase {
public:
- RTSystemServicesProtocolConjPort(etRuntime::IInterfaceItemOwner* actor, const std::string& name, int localId);
- RTSystemServicesProtocolConjPort(etRuntime::IInterfaceItemOwner* actor, const std::string& name, int localId, int idx);
+ RTSystemServicesProtocolConjPort(etRuntime::IInterfaceItemOwner* actor, const etRuntime::String& name, int localId);
+ RTSystemServicesProtocolConjPort(etRuntime::IInterfaceItemOwner* actor, const etRuntime::String& name, int localId, int idx);
virtual void destroy();
@@ -109,7 +109,7 @@ class RTSystemServicesProtocolConjPort : public etRuntime::PortBase {
class RTSystemServicesProtocolConjReplPort : public etRuntime::ReplicatedPortBase {
public:
- RTSystemServicesProtocolConjReplPort(etRuntime::IInterfaceItemOwner* actor, const std::string& name, int localId);
+ RTSystemServicesProtocolConjReplPort(etRuntime::IInterfaceItemOwner* actor, const etRuntime::String& name, int localId);
int getReplication() const { return getNInterfaceItems(); }
int getIndexOf(const etRuntime::InterfaceItemBase& ifitem) const { return ifitem.getIdx(); }
@@ -121,7 +121,7 @@ class RTSystemServicesProtocolConjReplPort : public etRuntime::ReplicatedPortBas
public: void stopDebugging();
protected:
- virtual etRuntime::InterfaceItemBase* createInterfaceItem(etRuntime::IInterfaceItemOwner* rcv, const std::string& name, int lid, int idx) {
+ virtual etRuntime::InterfaceItemBase* createInterfaceItem(etRuntime::IInterfaceItemOwner* rcv, const etRuntime::String& name, int lid, int idx) {
return new RTSystemServicesProtocolConjPort(rcv, name, lid, idx);
}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Map.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Map.cpp
new file mode 100644
index 000000000..35bd4188a
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Map.cpp
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2017 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "common/containers/Map.h"
+
+namespace etRuntime {
+
+size_t MapStats::ncreated = 0;
+size_t MapStats::ndestroyed = 0;
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Map.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Map.h
new file mode 100644
index 000000000..d77c53f5e
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Map.h
@@ -0,0 +1,232 @@
+/*******************************************************************************
+ * Copyright (c) 2017 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef MAP_H_
+#define MAP_H_
+
+#include "etDatatypes.h"
+#include "Pair.h"
+#include "Vector.h"
+
+namespace etRuntime {
+
+/**
+ * common map base class with counters for creations and destructions
+ */
+class MapStats {
+public:
+ static size_t getNCreated() { return ncreated; }
+ static size_t getNDestroyed() { return ndestroyed; }
+
+private:
+ template<class K, class V> friend class Map;
+ static size_t ncreated;
+ static size_t ndestroyed;
+};
+
+template<class Key, class Value>
+class Map {
+public:
+
+ typedef Pair<Key, Value> Entry;
+ typedef typename Vector<Entry>::iterator iterator;
+ typedef typename Vector<Entry>::const_iterator const_iterator;
+ typedef typename Vector<Entry>::reverse_iterator reverse_iterator;
+
+ /**
+ * default constructor
+ */
+ Map()
+ : _container()
+ {
+ ++MapStats::ncreated;
+ }
+
+ /**
+ * copy constructor
+ */
+ Map(const Map<Key, Value> &rhs)
+ : _container(rhs._container)
+ {
+ ++MapStats::ncreated;
+ }
+
+ /**
+ * virtual destructor
+ */
+ virtual ~Map(void) {
+ ++MapStats::ndestroyed;
+ }
+
+ /**
+ * Requests that the set capacity be at least enough to contain n elements.
+ *
+ * If n is greater than the current set capacity, the function causes the container
+ * to reallocate its storage increasing its capacity to n (or greater).
+ * In all other cases, the function call does not cause a reallocation and the set
+ * capacity is not affected.
+ *
+ * This function has no effect on the set size and cannot alter its elements.
+ */
+ void reserve(size_t n) {
+ _container.reserve(n);
+ }
+
+ /**
+ * returns the _size of this set
+ */
+ int size(void) const {
+ return _container.size();
+ }
+
+ /**
+ * Returns whether the set is empty (i.e. whether its size is 0).
+ * This function does not modify the container in any way.
+ * To clear the content of a set, see Map::clear.
+ */
+ bool empty(void) const {
+ return _container.empty();
+ }
+
+ void clear() {
+ _container.clear();
+ }
+
+ Value& operator[](const Key& key) {
+ for (iterator it=begin(); it!=end(); ++it) {
+ if (key==it->first) {
+ return it->second;
+ }
+ }
+
+ _container.push_back(Entry(key, Value()));
+ return _container.back().second;
+ }
+
+ iterator find(const Key& key) {
+ for (iterator it=begin(); it!=end(); ++it) {
+ if (key==(*it).first) {
+ return it;
+ }
+ }
+ return end();
+ }
+
+ const_iterator find(const Key& key) const {
+ for (const_iterator it=begin(); it!=end(); ++it) {
+ if (key==(*it).first) {
+ return it;
+ }
+ }
+ return end();
+ }
+
+ iterator erase(iterator position) {
+ return _container.erase(position);
+ }
+
+ size_t erase(const Key& key) {
+ iterator it = find(key);
+ if (it==end()) {
+ return 0;
+ }
+ else {
+ _container.erase(it);
+ return 1;
+ }
+ }
+
+ /**
+ * returns a pointer to the _data of this set (as a C array)
+ */
+ Entry* getData(void) {
+ return _container.getData();
+ }
+
+ /**
+ * returns a const pointer to the _data of this set (as a C array)
+ */
+ const Entry* getData(void) const {
+ return _container.getData();
+ }
+
+ /**
+ * copy assignment makes a deep copy
+ */
+ Map<Key, Value>& operator=(const Map<Key, Value> &rhs) {
+ _container = rhs._container;
+ return *this;
+ }
+
+ const_iterator begin() const {
+ return _container.begin();
+ }
+
+ const_iterator end() const {
+ return _container.end();
+ }
+
+ iterator begin() {
+ return _container.begin();
+ }
+
+ iterator end() {
+ return _container.end();
+ }
+
+ reverse_iterator rbegin() {
+ return _container.rbegin();
+ }
+
+ reverse_iterator rend() {
+ return _container.rend();
+ }
+
+protected:
+ Vector<Entry> _container;
+};
+
+/**
+ * comparison operator (expensive because not ordered - O(n^2))
+ */
+template<class Key, class Value>
+inline bool operator==(const Map<Key, Value> lhs, const Map<Key, Value> rhs) {
+ if (rhs.size()!=lhs.size()) {
+ return false;
+ }
+
+ // are all elements contained in rhs?
+ for (typename Map<Key, Value>::const_iterator it=lhs.begin(); it!=lhs.end(); ++it) {
+ // find key
+ typename Map<Key, Value>::const_iterator rit = rhs.find(it->first);
+ if (rit==rhs.end()) {
+ return false;
+ }
+ else {
+ // compare value
+ if (rit->second!=it->second) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+template<class Key, class Value>
+inline bool operator!=(const Map<Key, Value> &lhs, const Map<Key, Value> &rhs) {
+ return !(lhs==rhs);
+}
+
+} /* namespace etRuntime */
+#endif /* MAP_H_ */
+
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Pair.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Pair.h
new file mode 100644
index 000000000..ae61816e7
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Pair.h
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2017 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef PAIR_H_
+#define PAIR_H_
+
+#include "etDatatypes.h"
+
+namespace etRuntime {
+
+
+template<class T1, class T2>
+struct Pair {
+ Pair()
+ : first(), second()
+ { }
+ Pair(const T1& f, const T2& s)
+ : first(f), second(s)
+ { }
+
+ // copy constructor
+ // works if T1==U1 and T1==U2 or implicit conversions T1(U1) and T2(U2) exist
+ template<class U1, class U2>
+ Pair(const Pair<U1, U2>& p)
+ : first(p.first)
+ , second(p.second)
+ {
+ }
+
+ T1 first;
+ T2 second;
+};
+
+/**
+ * two pairs of the same pair of types are equal iff their members are equal.
+ */
+template<class T1, class T2>
+inline bool operator==(const Pair<T1, T2>& lhs, const Pair<T1, T2>& rhs) {
+ return lhs.first == rhs.first && lhs.second == rhs.second;
+}
+
+// uses operator==
+template<class T1, class T2>
+inline bool operator!=(const Pair<T1, T2>& lhs, const Pair<T1, T2>& rhs) {
+ return !(lhs==rhs);
+}
+
+// see http://www.cplusplus.com/reference/utility/pair/operators/
+template<class T1, class T2>
+inline bool operator<(const Pair<T1, T2>& lhs, const Pair<T1, T2>& rhs) {
+ return lhs.first < rhs.first
+ || (!(rhs.first < lhs.first) && lhs.second < rhs.second);
+}
+
+// uses operator<
+template<class T1, class T2>
+inline bool operator>(const Pair<T1, T2>& lhs, const Pair<T1, T2>& rhs) {
+ return rhs < lhs;
+}
+
+// uses operator<
+template<class T1, class T2>
+inline bool operator<=(const Pair<T1, T2>& lhs, const Pair<T1, T2>& rhs) {
+ return !(rhs < lhs);
+}
+
+// uses operator<
+template<class T1, class T2>
+inline bool operator>=(const Pair<T1, T2>& lhs, const Pair<T1, T2>& rhs) {
+ return !(lhs < rhs);
+}
+
+} /* namespace etRuntime */
+#endif /* PAIR_H_ */
+
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Set.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Set.cpp
new file mode 100644
index 000000000..e00d75d92
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Set.cpp
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2017 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "common/containers/Set.h"
+
+namespace etRuntime {
+
+size_t SetStats::ncreated = 0;
+size_t SetStats::ndestroyed = 0;
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Set.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Set.h
new file mode 100644
index 000000000..8fac8cada
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Set.h
@@ -0,0 +1,222 @@
+/*******************************************************************************
+ * Copyright (c) 2017 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef SET_H_
+#define SET_H_
+
+#include "etDatatypes.h"
+#include "Vector.h"
+
+namespace etRuntime {
+
+/**
+ * common set base class with counters for allocations and deallocations
+ */
+class SetStats {
+public:
+ static size_t getNCreated() { return ncreated; }
+ static size_t getNDestroyed() { return ndestroyed; }
+
+private:
+ template<class T> friend class Set;
+ static size_t ncreated;
+ static size_t ndestroyed;
+};
+
+template<class Type>
+class Set {
+public:
+
+ typedef typename Vector<Type>::iterator iterator;
+ typedef typename Vector<Type>::const_iterator const_iterator;
+ typedef typename Vector<Type>::reverse_iterator reverse_iterator;
+
+ /**
+ * default constructor
+ */
+ Set()
+ : _container()
+ {
+ ++SetStats::ncreated;
+ }
+
+ /**
+ * copy constructor
+ */
+ Set(const Set<Type> &rhs)
+ : _container(rhs._container)
+ {
+ ++SetStats::ncreated;
+ }
+
+ /**
+ * virtual destructor
+ */
+ virtual ~Set(void) {
+ ++SetStats::ndestroyed;
+ }
+
+ /**
+ * Requests that the set capacity be at least enough to contain n elements.
+ *
+ * If n is greater than the current set capacity, the function causes the container
+ * to reallocate its storage increasing its capacity to n (or greater).
+ * In all other cases, the function call does not cause a reallocation and the set
+ * capacity is not affected.
+ *
+ * This function has no effect on the set size and cannot alter its elements.
+ */
+ void reserve(size_t n) {
+ _container.reserve(n);
+ }
+
+ /**
+ * returns the _size of this set
+ */
+ int size(void) const {
+ return _container.size();
+ }
+
+ /**
+ * Returns whether the set is empty (i.e. whether its size is 0).
+ * This function does not modify the container in any way.
+ * To clear the content of a set, see Set::clear.
+ */
+ bool empty(void) const {
+ return _container.empty();
+ }
+
+ void clear() {
+ _container.clear();
+ }
+
+ bool insert(const Type& t) {
+ iterator it = find(t);
+ if (it==end()) {
+ _container.push_back(t);
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ iterator find(const Type& t) {
+ for (iterator it=begin(); it!=end(); ++it) {
+ if (t==*it) {
+ return it;
+ }
+ }
+ return end();
+ }
+
+ const_iterator find(const Type& t) const {
+ for (const_iterator it=begin(); it!=end(); ++it) {
+ if (t==*it) {
+ return it;
+ }
+ }
+ return end();
+ }
+
+ iterator erase(iterator position) {
+ return _container.erase(position);
+ }
+
+ size_t erase(const Type& t) {
+ iterator it = find(t);
+ if (it==end()) {
+ return 0;
+ }
+ else {
+ _container.erase(it);
+ return 1;
+ }
+ }
+
+ /**
+ * returns a pointer to the _data of this set (as a C array)
+ */
+ Type* getData(void) {
+ return _container.getData();
+ }
+
+ /**
+ * returns a const pointer to the _data of this set (as a C array)
+ */
+ const Type* getData(void) const {
+ return _container.getData();
+ }
+
+ /**
+ * copy assignment makes a deep copy
+ */
+ Set<Type>& operator=(const Set<Type> &rhs) {
+ _container = rhs._container;
+ return *this;
+ }
+
+ const_iterator begin() const {
+ return _container.begin();
+ }
+
+ const_iterator end() const {
+ return _container.end();
+ }
+
+ iterator begin() {
+ return _container.begin();
+ }
+
+ iterator end() {
+ return _container.end();
+ }
+
+ reverse_iterator rbegin() {
+ return _container.rbegin();
+ }
+
+ reverse_iterator rend() {
+ return _container.rend();
+ }
+
+protected:
+ Vector<Type> _container;
+};
+
+/**
+ * comparison operator (expensive because not ordered - O(n^2))
+ */
+template<class Type>
+inline bool operator==(const Set<Type> lhs, const Set<Type> rhs) {
+ if (rhs.size()!=lhs.size()) {
+ return false;
+ }
+
+ // are all elements contained in rhs?
+ for (typename Set<Type>::const_iterator it=lhs.begin(); it!=lhs.end(); ++it) {
+ if (rhs.find(*it)==rhs.end()) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+template<class Type>
+inline bool operator!=(const Set<Type> &lhs, const Set<Type> &rhs) {
+ return !(lhs==rhs);
+}
+
+} /* namespace etRuntime */
+#endif /* SET_H_ */
+
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/String.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/String.cpp
new file mode 100644
index 000000000..a82c11dd8
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/String.cpp
@@ -0,0 +1,169 @@
+/*******************************************************************************
+ * Copyright (c) 2017 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "common/containers/String.h"
+
+namespace etRuntime {
+
+size_t String::nallocs = 0;
+size_t String::ndeallocs = 0;
+size_t String::ncreated = 0;
+size_t String::ndestroyed = 0;
+
+String::String()
+: _size(0)
+, _data(new char[1])
+{
+ ++nallocs;
+ ++ncreated;
+ _data[0] = '\0';
+}
+
+String::~String(void) {
+ ++ndestroyed;
+ if (_data) {
+ delete[] _data;
+ ++ndeallocs;
+ }
+}
+
+/*
+ * added this according to
+ * http://stackoverflow.com/questions/1634359/is-there-a-reverse-function-for-strstr
+ */
+static const char *rstrstr(const char * s1, const char * s2) {
+ size_t s1len = strlen(s1);
+ size_t s2len = strlen(s2);
+ const char *s;
+
+ if (s2len > s1len) {
+ return NULL;
+ }
+ for (s = s1 + s1len - s2len; s >= s1; --s) {
+ if (strncmp(s, s2, s2len) == 0) {
+ return s;
+ }
+ }
+ return NULL;
+}
+
+String& String::operator=(const char *rhs) {
+ if (rhs && rhs!=this->_data) {
+ size_t new_size = std::strlen(rhs) + 1;
+ if (new_size > _size) {
+ _size = new_size;
+ if (_data) {
+ delete[] _data;
+ ++ndeallocs;
+ }
+ _data = new char[new_size];
+ ++nallocs;
+ }
+ std::strcpy(this->_data, rhs);
+ }
+ return *this;
+}
+
+const String String::operator+=(const char* rhs) {
+ if (rhs) {
+ size_t new_size = this->length() + std::strlen(rhs) + 1;
+ if (new_size > _size) {
+ _size = new_size;
+ char* new_data = new char[new_size];
+ ++nallocs;
+ if (_data) {
+ std::strcpy(new_data, _data);
+ delete[] _data;
+ ++ndeallocs;
+ }
+ else {
+ new_data[0] = '\0';
+ }
+ _data = new_data;
+ }
+ std::strcat(this->_data, rhs);
+ }
+
+ // Note: this function returns a const, not a const&!
+ // this prohibits things like (a + b) = c
+ return *this;
+}
+
+const String String::operator+=(char c) {
+ size_t new_size = this->length() + 2;
+ if (new_size > _size) {
+ _size = new_size;
+ char* new_data = new char[new_size];
+ ++nallocs;
+ if (_data) {
+ std::strcpy(new_data, _data);
+ delete[] _data;
+ ++ndeallocs;
+ }
+ _data = new_data;
+ }
+ _data[new_size-2] = c;
+ _data[new_size-1] = '\0';
+
+ // Note: this function returns a const, not a const&!
+ // this prohibits things like (a + b) = c
+ return *this;
+}
+
+size_t String::find(const String& str, size_t pos) const {
+ if (pos>length()) {
+ return npos;
+ }
+ return std::strstr(_data + pos, str._data) - _data;
+}
+
+size_t String::find(const char* str, size_t pos) const {
+ if (pos>length()) {
+ return npos;
+ }
+ return std::strstr(_data + pos, str) - _data;
+}
+
+size_t String::find(char c, size_t pos) const {
+ if (pos>length()) {
+ return npos;
+ }
+ return std::strchr(_data + pos, c) - _data;
+}
+
+size_t String::rfind(const String& str) const {
+ return rstrstr(_data, str._data) - _data;
+}
+
+size_t String::rfind(const char* str) const {
+ return rstrstr(_data, str) - _data;
+}
+
+size_t String::rfind(char c) const {
+ return std::strrchr(_data, c) - _data;
+}
+
+
+String String::substr(size_t pos, size_t len) const {
+ if (pos > length()) {
+ return String("");
+ }
+
+ String result(_data+pos);
+ if (len < result.length()) {
+ result._data[len] = '\0';
+ }
+
+ return result;
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/String.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/String.h
new file mode 100644
index 000000000..70ac624b8
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/String.h
@@ -0,0 +1,318 @@
+/*******************************************************************************
+ * Copyright (c) 2017 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef STRING_H_
+#define STRING_H_
+
+#include <cstddef>
+#include <cstring>
+
+namespace etRuntime {
+
+/**
+ * a static size string class that basically encapsulates a C string
+ */
+class String {
+public:
+ /**
+ * default constructor is empty string
+ */
+ String();
+
+ /**
+ * copy constructor calls operator=(const char *rhs)
+ */
+ String(const String &rhs)
+ : _size(0)
+ , _data(0)
+ {
+ ++ncreated;
+ operator=(rhs._data);
+ }
+
+ /**
+ * constructor calls operator=(const char *rhs)
+ */
+ String(const char *rhs)
+ : _size(0)
+ , _data(0)
+ {
+ ++ncreated;
+ operator=(rhs);
+ }
+
+ /**
+ * virtual destructor
+ */
+ virtual ~String(void);
+
+
+ /**
+ * returns the length of the C string stored
+ */
+ size_t length(void) const
+ {
+ return std::strlen(this->_data);
+ }
+
+ /**
+ * returns a const char * pointer to the data of this array
+ */
+ const char* c_str(void) const
+ {
+ return this->_data;
+ }
+
+ /**
+ * returns the character at the given position. If index is out of range 0 is returned
+ */
+ char operator[](int index) const {
+ return (index < 0 || index >= (int)_size) ? 0 : _data[index];
+ }
+
+ /**
+ * forwards to operator=(const char *rhs)
+ */
+ String& operator=(const String &rhs)
+ {
+ return operator=(rhs._data);
+ }
+
+ /**
+ * creates a copy of the rhs
+ */
+ String& operator=(const char *rhs);
+
+ //
+ // string concatenation
+ //
+
+ /*
+ * concatenates the rhs to the end of the string.
+ */
+ const String operator+=(const String& rhs) {
+ return operator+=(rhs._data);
+ }
+
+ /*
+ * concatenates the rhs to the end of the string.
+ */
+ const String operator+=(const char* rhs);
+
+ /*
+ * concatenates the c to the end of the string.
+ */
+ const String operator+=(char c);
+
+ //
+ // comparison
+ //
+
+ /**
+ * compares two strings
+ */
+ int compare(const String& rhs) const {
+ return std::strcmp(this->_data, rhs._data);
+ }
+ int compareXX(const String& rhs) const {
+ return std::strcmp(this->_data, rhs._data);
+ }
+//
+// /**
+// * compares a string with a C-String
+// */
+// int compare(const char *rhs) const {
+// return strcmp(this->_data, rhs);
+// }
+
+ //
+ // find
+ //
+ static const size_t npos = -1;
+
+ size_t find(const String& str, size_t pos = 0) const;
+ size_t find(const char* str, size_t pos = 0) const;
+ size_t find(char c, size_t pos = 0) const;
+
+ size_t rfind(const String& str) const;
+ size_t rfind(const char* str) const;
+ size_t rfind(char c) const;
+
+ //
+ // sub strings
+ //
+ String substr(size_t pos = 0, size_t len = npos) const;
+
+ static size_t getNAllocations() { return nallocs; }
+ static size_t getNDeallocations() { return ndeallocs; }
+ static size_t getNCreated() { return ncreated; }
+ static size_t getNDestroyed() { return ndestroyed; }
+
+private:
+ static size_t nallocs;
+ static size_t ndeallocs;
+ static size_t ncreated;
+ static size_t ndestroyed;
+
+ size_t _size;
+ char* _data;
+};
+
+//
+// string concatenation
+//
+
+/**
+ * concatenates lhs and rhs.
+ */
+inline const String operator+(const String &lhs, const String &rhs) {
+ // make a copy and add
+ return String(lhs) += rhs;
+}
+
+/**
+ * concatenates lhs and rhs.
+ */
+inline const String operator+(const String &lhs, const char* rhs) {
+ // make a copy and add
+ return String(lhs) += rhs;
+}
+
+/**
+ * concatenates lhs and c
+ */
+inline const String operator+(const String &lhs, char c) {
+ // make a copy and add
+ String result(lhs);
+ result += c;
+ return result;
+}
+
+/**
+ * concatenates lhs and rhs.
+ */
+inline const String operator+(const char* lhs, const String& rhs) {
+ // create a string and add
+ String result(lhs);
+ result += rhs;
+ return result;
+}
+
+/**
+ * concatenates c and rhs.
+ */
+inline const String operator+(char c, const String& rhs) {
+ // create a string and add
+ String result("");
+ result += c;
+ result += rhs;
+ return result;
+}
+
+//
+// string comparison
+//
+
+/**
+ * compares two strings
+ */
+inline bool operator==(const String& lhs, const String &rhs) {
+ return lhs.compare(rhs)==0;
+}
+
+/**
+ * compares a string with a C-string
+ */
+inline bool operator==(const String& lhs, const char *rhs) {
+ return lhs.compare(rhs)==0;
+}
+
+/**
+ * compares a C-string with a string
+ */
+inline bool operator==(const char* lhs, const String& rhs) {
+ return rhs.compare(lhs)==0;
+}
+
+/**
+ * compares two strings
+ */
+inline bool operator!=(const String &lhs, const String &rhs) {
+ return !(lhs == rhs);
+}
+
+/**
+ * compares a string and a C-string
+ */
+inline bool operator!=(const String &lhs, const char *rhs) {
+ return !(lhs == rhs);
+}
+
+/**
+ * compares a C-string and a string
+ */
+inline bool operator!=(const char* lhs, const String& rhs) {
+ return !(lhs == rhs);
+}
+
+inline bool operator<(const String &lhs, const String& rhs) {
+ return lhs.compare(rhs) < 0;
+}
+
+inline bool operator<(const String &lhs, const char* rhs) {
+ return lhs.compare(rhs) < 0;
+}
+
+inline bool operator<(const char* lhs, const String& rhs) {
+ return rhs.compare(lhs) > 0;
+}
+
+inline bool operator<=(const String &lhs, const String& rhs) {
+ return lhs.compare(rhs) <= 0;
+}
+
+inline bool operator<=(const String &lhs, const char* rhs) {
+ return lhs.compare(rhs) <= 0;
+}
+
+inline bool operator<=(const char* lhs, const String& rhs) {
+ return rhs.compare(lhs) >= 0;
+}
+
+inline bool operator>(const String &lhs, const String& rhs) {
+ return lhs.compare(rhs) > 0;
+}
+
+inline bool operator>(const String &lhs, const char* rhs) {
+ return lhs.compare(rhs) > 0;
+}
+
+inline bool operator>(const char* lhs, const String& rhs) {
+ return rhs.compare(lhs) < 0;
+}
+
+inline bool operator>=(const String &lhs, const String& rhs) {
+ return lhs.compare(rhs) >= 0;
+}
+
+inline bool operator>=(const String &lhs, const char* rhs) {
+ return lhs.compare(rhs) >= 0;
+}
+
+inline bool operator>=(const char* lhs, const String& rhs) {
+ return rhs.compare(lhs) <= 0;
+}
+
+} /* namespace etRuntime */
+
+#endif /* STRING_H_ */
+
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Vector.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Vector.cpp
new file mode 100644
index 000000000..e688803eb
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Vector.cpp
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2017 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "common/containers/Vector.h"
+
+namespace etRuntime {
+
+size_t VectorStats::nallocs = 0;
+size_t VectorStats::ndeallocs = 0;
+size_t VectorStats::ncreated = 0;
+size_t VectorStats::ndestroyed = 0;
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Vector.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Vector.h
new file mode 100644
index 000000000..065a58f9d
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/containers/Vector.h
@@ -0,0 +1,334 @@
+/*******************************************************************************
+ * Copyright (c) 2017 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef VECTOR_H_
+#define VECTOR_H_
+
+#include "etDatatypes.h"
+#include <cstring>
+
+namespace etRuntime {
+
+/**
+ * common vector base class with counters for allocations and deallocations
+ */
+class VectorStats {
+public:
+ static size_t getNAllocations() { return nallocs; }
+ static size_t getNDeallocations() { return ndeallocs; }
+ static size_t getNCreated() { return ncreated; }
+ static size_t getNDestroyed() { return ndestroyed; }
+
+private:
+ template<class T> friend class Vector;
+ static size_t nallocs;
+ static size_t ndeallocs;
+ static size_t ncreated;
+ static size_t ndestroyed;
+};
+
+template<class Type>
+class Vector {
+public:
+
+ typedef Type* iterator;
+ typedef const Type* const_iterator;
+
+ class reverse_iterator {
+ public:
+ reverse_iterator(Type* d) : _current(d) {}
+ reverse_iterator(const reverse_iterator& rhs) : _current(rhs._current) {}
+
+ reverse_iterator& operator=(const reverse_iterator& rhs) {
+ _current = rhs._current;
+ return *this;
+ }
+
+ Type operator*() const {
+ Type* tmp = _current;
+ return *(--tmp);
+ }
+ Type* operator->() const {
+ return &(operator*());
+ }
+
+ reverse_iterator& operator++() {
+ --_current;
+ return *this;
+ }
+ reverse_iterator operator++(int) {
+ reverse_iterator tmp = *this;
+ --_current;
+ return tmp;
+ }
+ reverse_iterator& operator--() {
+ ++_current;
+ return *this;
+ }
+ reverse_iterator operator--(int) {
+ reverse_iterator tmp = *this;
+ ++_current;
+ return tmp;
+ }
+
+ bool operator==(const reverse_iterator& rhs) const {
+ return _current == rhs._current;
+ }
+ bool operator!=(const reverse_iterator& rhs) const {
+ return !(operator==(rhs));
+ }
+ private:
+ Type* _current;
+ };
+
+ /**
+ * default constructor
+ */
+ Vector()
+ : _size(0)
+ , _capacity(0)
+ , _data(0)
+ {
+ ++VectorStats::ncreated;
+ }
+
+ /**
+ * copy constructor
+ */
+ Vector(const Vector<Type> &rhs)
+ : _size(rhs._size)
+ , _capacity(rhs._size)
+ , _data(new Type[rhs._size])
+ {
+ ++VectorStats::ncreated;
+ ++VectorStats::nallocs;
+ for (int i = 0; i < _size; i++) {
+ _data[i] = rhs[i];
+ }
+ }
+
+ /**
+ * initializes each vector element to t
+ */
+ Vector(size_t size, const Type& t=Type())
+ : _size(size)
+ , _capacity(size)
+ , _data(new Type[size])
+ {
+ ++VectorStats::ncreated;
+ ++VectorStats::nallocs;
+ for (int i = 0; i < _size; i++) {
+ _data[i] = t;
+ }
+ }
+
+ /**
+ * virtual destructor
+ */
+ virtual ~Vector(void) {
+ ++VectorStats::ndestroyed;
+ if (_data) {
+ delete[] _data;
+ ++VectorStats::ndeallocs;
+ }
+ }
+
+ /**
+ * Requests that the vector capacity be at least enough to contain n elements.
+ *
+ * If n is greater than the current vector capacity, the function causes the container
+ * to reallocate its storage increasing its capacity to n (or greater).
+ * In all other cases, the function call does not cause a reallocation and the vector
+ * capacity is not affected.
+ *
+ * This function has no effect on the vector size and cannot alter its elements.
+ */
+ void reserve(size_t n) {
+ if (n > _capacity) {
+ _capacity = n;
+ Type* new_data = new Type[_capacity];
+ ++VectorStats::nallocs;
+ if (_data) {
+ for (int i = 0; i < _size; i++) {
+ new_data[i] = _data[i];
+ }
+ delete[] _data;
+ ++VectorStats::ndeallocs;
+ }
+ _data = new_data;
+ }
+ }
+
+ /**
+ * returns the _size of this vector
+ */
+ int size(void) const {
+ return _size;
+ }
+
+ /**
+ * Returns whether the vector is empty (i.e. whether its size is 0).
+ * This function does not modify the container in any way.
+ * To clear the content of a vector, see Vector::clear.
+ */
+ bool empty(void) const {
+ return _size==0;
+ }
+
+ void clear() {
+ _size = 0;
+ _capacity = 0;
+ if (_data) {
+ delete[] _data;
+ ++VectorStats::ndeallocs;
+ }
+ _data = 0;
+ }
+
+ void push_back(const Type& t) {
+ if (_size>=_capacity) {
+ reserve(_size + const_grow_by);
+ }
+
+ _data[_size++] = t;
+ }
+
+ void pop_back() {
+ if (_size>0) {
+ --_size;
+ }
+ }
+
+ iterator erase (iterator position) {
+ if (_size>0 && (position >= _data) && (position < _data+_size)) {
+ // copy following elements one position down each
+ iterator curr = position;
+ iterator next = position + 1;
+ for (; next!=end(); ++curr, ++next) {
+ *curr = *next;
+ }
+ --_size;
+ }
+ return position;
+ }
+
+ /**
+ * returns a pointer to the _data of this vector (as a C array)
+ */
+ Type* getData(void) {
+ return this->_data;
+ }
+
+ /**
+ * returns a const pointer to the _data of this vector (as a C array)
+ */
+ const Type* getData(void) const {
+ return this->_data;
+ }
+
+ /**
+ * indexed access without range check
+ */
+ Type& operator[](int index) {
+ return _data[index];
+ }
+
+ /**
+ * indexed access without range check
+ */
+ const Type& operator[](int index) const {
+ return _data[index];
+ }
+
+ Type& front() {
+ return _data[0];
+ }
+
+ const Type& front() const {
+ return _data[0];
+ }
+
+ Type& back() {
+ return _data[_size-1];
+ }
+
+ const Type& back() const {
+ return _data[_size-1];
+ }
+
+ /**
+ * copy assignment makes a deep copy
+ */
+ Vector<Type>& operator=(const Vector<Type> &rhs) {
+ if (&rhs!=this) {
+ _size = rhs._size;
+ if (_size > _capacity) {
+ _capacity = _size;
+ if (_data) {
+ delete[] _data;
+ ++VectorStats::ndeallocs;
+ }
+ _data = new Type[_capacity];
+ ++VectorStats::nallocs;
+ }
+ for (int i = 0; i < _size; i++) {
+ _data[i] = rhs[i];
+ }
+ }
+ return *this;
+ }
+
+ /**
+ * comparison operator based on memcmp()
+ */
+ bool operator==(const Vector<Type> &rhs) const {
+ return _size!=rhs._size ? false : std::memcmp(this->_data, rhs._data, _size*sizeof(*_data)) == 0;
+ }
+ bool operator!=(const Vector<Type> &rhs) const {
+ return !(operator==(rhs));
+ }
+
+ const_iterator begin() const {
+ return _data;
+ }
+
+ const_iterator end() const {
+ return _data + _size;
+ }
+
+ iterator begin() {
+ return _data;
+ }
+
+ iterator end() {
+ return _data + _size;
+ }
+
+ reverse_iterator rbegin() {
+ return reverse_iterator(_data + _size);
+ }
+
+ reverse_iterator rend() {
+ return reverse_iterator(_data);
+ }
+
+protected:
+ size_t _size;
+ size_t _capacity;
+ Type* _data; ///< the C array holding the _data
+
+ static const size_t const_grow_by = 4;
+};
+
+} /* namespace etRuntime */
+#endif /* VECTOR_H_ */
+
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.cpp
index b2dedc349..7216a1640 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.cpp
@@ -15,7 +15,6 @@
#include "common/modelbase/ActorClassBase.h"
#include "common/modelbase/SubSystemClassBase.h"
#include "common/modelbase/InterfaceItemBase.h"
-#include <iostream>
namespace etRuntime {
@@ -32,66 +31,76 @@ DebuggingService::DebuggingService() :
}
const InterfaceItemBase* DebuggingService::getPort(const Address& address) const {
- std::map<Address, const InterfaceItemBase*>::const_iterator it = m_portInstances.find(address);
+ Map<Address, const InterfaceItemBase*>::const_iterator it = m_portInstances.find(address);
if (it != m_portInstances.end())
return it->second;
return 0;
}
-void DebuggingService::addMessageAsyncOut(const Address& source, const Address& target, const std::string& msg) {
+void DebuggingService::addMessageAsyncOut(const Address& source, const Address& target, const String& msg) {
const InterfaceItemBase* srcPort = getPort(source);
const InterfaceItemBase* tgtPort = getPort(target);
- if (srcPort != 0 && tgtPort != 0)
- m_asyncLogger.addMessageAsyncOut(srcPort->getActor()->getInstancePath(), tgtPort->getActor()->getInstancePath(),
- msg);
+ if (srcPort != 0 && tgtPort != 0) {
+ etRuntime::String srcPath = srcPort->getActor()->getInstancePath();
+ etRuntime::String tgtPath = tgtPort->getActor()->getInstancePath();
+ m_asyncLogger.addMessageAsyncOut(srcPath, tgtPath, msg);
+ }
}
-void DebuggingService::addMessageAsyncIn(const Address& source, const Address& target, const std::string& msg) {
+void DebuggingService::addMessageAsyncIn(const Address& source, const Address& target, const String& msg) {
const InterfaceItemBase* srcPort = getPort(source);
const InterfaceItemBase* tgtPort = getPort(target);
- if (srcPort != 0 && tgtPort != 0)
- m_asyncLogger.addMessageAsyncIn(srcPort->getActor()->getInstancePath(), tgtPort->getActor()->getInstancePath(),
- msg);
+ if (srcPort != 0 && tgtPort != 0) {
+ etRuntime::String srcPath = srcPort->getActor()->getInstancePath();
+ etRuntime::String tgtPath = tgtPort->getActor()->getInstancePath();
+ m_asyncLogger.addMessageAsyncIn(srcPath, tgtPath, msg);
+ }
}
-void DebuggingService::addMessageSyncCall(const Address& source, const Address& target, const std::string& msg) {
+void DebuggingService::addMessageSyncCall(const Address& source, const Address& target, const String& msg) {
const InterfaceItemBase* srcPort = getPort(source);
const InterfaceItemBase* tgtPort = getPort(target);
- if (srcPort != 0 && tgtPort != 0)
- m_asyncLogger.addMessageSyncCall(srcPort->getActor()->getInstancePath(), tgtPort->getActor()->getInstancePath(),
- msg);
+ if (srcPort != 0 && tgtPort != 0) {
+ etRuntime::String srcPath = srcPort->getActor()->getInstancePath();
+ etRuntime::String tgtPath = tgtPort->getActor()->getInstancePath();
+ m_asyncLogger.addMessageSyncCall(srcPath, tgtPath, msg);
+ }
}
-void DebuggingService::addMessageSyncReturn(const Address& source, const Address& target, const std::string& msg) {
+void DebuggingService::addMessageSyncReturn(const Address& source, const Address& target, const String& msg) {
const InterfaceItemBase* srcPort = getPort(source);
const InterfaceItemBase* tgtPort = getPort(target);
- if (srcPort != 0 && tgtPort != 0)
+ if (srcPort != 0 && tgtPort != 0) {
m_asyncLogger.addMessageSyncReturn(srcPort->getActor()->getInstancePath(),
tgtPort->getActor()->getInstancePath(), msg);
+ }
}
-void DebuggingService::addActorState(const ActorClassBase& actor, const std::string& state) {
- m_asyncLogger.addActorState(actor.getInstancePath(), state);
+void DebuggingService::addActorState(const ActorClassBase& actor, const String& state) {
+ etRuntime::String instancePath = actor.getInstancePath();
+ m_asyncLogger.addActorState(instancePath, state);
}
-void DebuggingService::addMessageActorCreate(const SubSystemClassBase& parent, const std::string& refName) {
- m_asyncLogger.addMessageActorCreate(parent.getInstancePath(),
- parent.getInstancePath() + IRTObject::PATH_DELIM + refName);
+void DebuggingService::addMessageActorCreate(const SubSystemClassBase& parent, const String& refName) {
+ etRuntime::String parentPath = parent.getInstancePath();
+ m_asyncLogger.addMessageActorCreate(parentPath, String(parentPath) + IRTObject::PATH_DELIM + refName);
}
-void DebuggingService::addMessageActorCreate(const ActorClassBase& parent, const std::string& refName) {
- m_asyncLogger.addMessageActorCreate(parent.getInstancePath(),
- parent.getInstancePath() + IRTObject::PATH_DELIM + refName);
+void DebuggingService::addMessageActorCreate(const ActorClassBase& parent, const String& refName) {
+ etRuntime::String parentPath = parent.getInstancePath();
+ m_asyncLogger.addMessageActorCreate(parentPath, String(parentPath) + IRTObject::PATH_DELIM + refName);
}
void DebuggingService::addMessageActorDestroy(const ActorClassBase& inst) {
+ etRuntime::String parentPath = inst.getParent()->getInstancePath();
+ etRuntime::String instancePath = inst.getInstancePath();
//if (!(inst.getParent() instanceof OptionalActorInterfaceBase))
- m_asyncLogger.addMessageActorDestroy(inst.getParent()->getInstancePath(), inst.getInstancePath());
+ m_asyncLogger.addMessageActorDestroy(parentPath, instancePath);
}
-void DebuggingService::addVisibleComment(const std::string& comment) {
+void DebuggingService::addVisibleComment(const String& comment) {
m_asyncLogger.addVisibleComment(comment);
}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.h
index 0ac9e6354..ff070c243 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.h
@@ -14,11 +14,10 @@
#define DEBUGGINGSERVICE_H_
#include "common/debugging/MSCLogger.h"
+#include "common/containers/Map.h"
#include "common/messaging/Address.h"
#include "etDatatypes.h"
#include "common/modelbase/InterfaceItemBase.h"
-#include <string>
-#include <map>
namespace etRuntime {
@@ -33,15 +32,15 @@ public:
static DebuggingService& getInstance();
- void addMessageAsyncOut(const Address& source, const Address& target, const std::string& msg);
- void addMessageAsyncIn(const Address& source, const Address& target, const std::string& msg);
- void addMessageSyncCall(const Address& source, const Address& target, const std::string& msg);
- void addMessageSyncReturn(const Address& source, const Address& target, const std::string& msg);
- void addActorState(const ActorClassBase& actor, const std::string& state);
- void addMessageActorCreate(const SubSystemClassBase& parent, const std::string& refName);
- void addMessageActorCreate(const ActorClassBase& parent, const std::string& refName);
+ void addMessageAsyncOut(const Address& source, const Address& target, const String& msg);
+ void addMessageAsyncIn(const Address& source, const Address& target, const String& msg);
+ void addMessageSyncCall(const Address& source, const Address& target, const String& msg);
+ void addMessageSyncReturn(const Address& source, const Address& target, const String& msg);
+ void addActorState(const ActorClassBase& actor, const String& state);
+ void addMessageActorCreate(const SubSystemClassBase& parent, const String& refName);
+ void addMessageActorCreate(const ActorClassBase& parent, const String& refName);
void addMessageActorDestroy(const ActorClassBase& inst);
- void addVisibleComment(const std::string& comment);
+ void addVisibleComment(const String& comment);
void addPortInstance(const InterfaceItemBase& port);
void removePortInstance(const InterfaceItemBase& port);
@@ -52,7 +51,7 @@ private:
MSCLogger m_asyncLogger;
MSCLogger m_syncLogger;
- std::map<Address, const InterfaceItemBase*> m_portInstances;
+ Map<Address, const InterfaceItemBase*> m_portInstances;
const InterfaceItemBase* getPort(const Address& address) const;
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFilter.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFilter.cpp
index 09d9c153b..db011e4cb 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFilter.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFilter.cpp
@@ -12,8 +12,6 @@
#include "common/debugging/MSCFilter.h"
#include "etStdDatatypes.h"
-#include <list>
-#include <string>
namespace etRuntime {
@@ -25,10 +23,10 @@ void MSCFilter::addFilter(FilterItem filter) {
filterList.push_back(filter);
}
-etBool MSCFilter::applyTo(const std::string& text) {
+etBool MSCFilter::applyTo(const String& text) {
if (filterList.empty())
return true; // no filters -> all messages will be logged
- std::list<FilterItem>::iterator it = filterList.begin();
+ Vector<FilterItem>::iterator it = filterList.begin();
for (; it != filterList.end(); ++it) {
if (text.compare((*it).filter) == 0)
return !(*it).exclude;
@@ -36,13 +34,13 @@ etBool MSCFilter::applyTo(const std::string& text) {
return false;
}
-std::string MSCFilter::reduceString(const std::string& string) {
+String MSCFilter::reduceString(const String& text) {
// if (filterList.size() == 1)
// //TODO: filtering with regular expression
// // return string.replaceFirst(filterList.front().filter, "");
// return string;
// else
- return string;
+ return text;
}
} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFilter.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFilter.h
index a3c5d98d6..6ec0f1a84 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFilter.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFilter.h
@@ -14,8 +14,8 @@
#define MSCFILTER_H_
#include "etDatatypes.h"
-#include <list>
-#include <string>
+#include "common/containers/String.h"
+#include "common/containers/Vector.h"
namespace etRuntime {
@@ -23,14 +23,18 @@ class MSCFilter {
public:
class FilterItem {
public:
- FilterItem(const std::string& filter_, etBool exclude_) :
- exclude(exclude_),
- filter(filter_) {
+ FilterItem(const String& filter_, etBool exclude_)
+ : exclude(exclude_)
+ , filter(filter_)
+ {
+ }
+ FilterItem()
+ : exclude()
+ , filter()
+ {
}
etBool exclude;
- std::string filter;
- private:
- FilterItem();
+ String filter;
};
MSCFilter();
@@ -38,11 +42,11 @@ public:
}
void addFilter(FilterItem filter);
- etBool applyTo(const std::string& text);
- std::string reduceString(const std::string& string);
+ etBool applyTo(const String& text);
+ String reduceString(const String& text);
private:
- std::list<FilterItem> filterList;
+ Vector<FilterItem> filterList;
};
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFunctionObject.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFunctionObject.cpp
index 6b7d6ca94..b75e84e95 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFunctionObject.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFunctionObject.cpp
@@ -15,17 +15,17 @@
using namespace etRuntime;
-MSCFunctionObject::MSCFunctionObject(const std::string& objectName, const std::string& message) :
+MSCFunctionObject::MSCFunctionObject(const String& objectName, const String& message) :
m_syncLogger(DebuggingService::getInstance().getSyncLogger()),
m_targetName(objectName),
- m_sourceName(m_syncLogger.getObjectName())
+ m_sourceName(m_syncLogger.getObjectName().c_str())
{
- m_syncLogger.setObjectName(m_targetName);
- m_syncLogger.addMessageSyncCall(m_sourceName, m_targetName, message);
+ m_syncLogger.setObjectName(m_targetName.c_str());
+ m_syncLogger.addMessageSyncCall(m_sourceName.c_str(), m_targetName.c_str(), message.c_str());
}
MSCFunctionObject::~MSCFunctionObject() {
- m_syncLogger.setObjectName(m_sourceName);
- m_syncLogger.addMessageSyncReturn(m_sourceName, m_targetName, "return");
+ m_syncLogger.setObjectName(m_sourceName.c_str());
+ m_syncLogger.addMessageSyncReturn(m_sourceName.c_str(), m_targetName.c_str(), "return");
}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFunctionObject.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFunctionObject.h
index e521ce532..898b9783b 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFunctionObject.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCFunctionObject.h
@@ -13,20 +13,20 @@
#ifndef SRC_COMMON_DEBUGGING_MSCFUNCTIONOBJECT_H_
#define SRC_COMMON_DEBUGGING_MSCFUNCTIONOBJECT_H_
-#include <string>
#include "common/debugging/MSCLogger.h"
+#include "common/containers/String.h"
namespace etRuntime {
class MSCFunctionObject {
public:
- MSCFunctionObject(const std::string& objectName, const std::string& message);
+ MSCFunctionObject(const String& objectName, const String& message);
~MSCFunctionObject();
private:
MSCLogger& m_syncLogger;
- const std::string m_targetName;
- const std::string m_sourceName;
+ const String m_targetName;
+ const String m_sourceName;
};
} // namespace etRuntime
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCLogger.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCLogger.cpp
index 528ea0087..7651e09e4 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCLogger.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCLogger.cpp
@@ -14,8 +14,6 @@
#include "common/debugging/MSCLogger.h"
#include "debugging/etLogger.h"
#include "etDatatypes.h"
-#include <list>
-#include <string>
namespace etRuntime {
@@ -36,7 +34,7 @@ MSCLogger::~MSCLogger() {
etMutex_destruct(&m_mutex);
}
-void MSCLogger::setMSC(const std::string& msc_name, const std::string& path) {
+void MSCLogger::setMSC(const String& msc_name, const String& path) {
m_msc_name = msc_name;
m_path = path;
if(m_filter != NULL)
@@ -50,78 +48,82 @@ void MSCLogger::open() {
etMutex_leave(&m_mutex);
}
-void MSCLogger::addMessageAsyncOut(const std::string& source, const std::string& target, const std::string& message) {
+void MSCLogger::addMessageAsyncOut(const String& source, const String& target, const String& message) {
etMutex_enter(&m_mutex);
createLine(source, " >-- ", target, message);
etMutex_leave(&m_mutex);
}
-void MSCLogger::addMessageAsyncIn(const std::string& source, const std::string& target, const std::string& message) {
+void MSCLogger::addMessageAsyncIn(const String& source, const String& target, const String& message) {
etMutex_enter(&m_mutex);
createLine(source, " --> ", target, message);
etMutex_leave(&m_mutex);
}
-void MSCLogger::addMessageSyncCall(const std::string& source, const std::string& target, const std::string& message) {
+void MSCLogger::addMessageSyncCall(const String& source, const String& target, const String& message) {
etMutex_enter(&m_mutex);
createLine(source, " ==> ", target, message);
etMutex_leave(&m_mutex);
}
-void MSCLogger::addMessageSyncReturn(const std::string& source, const std::string& target, const std::string& message) {
+void MSCLogger::addMessageSyncReturn(const String& source, const String& target, const String& message) {
etMutex_enter(&m_mutex);
createLine(source, " <== ", target, message);
etMutex_leave(&m_mutex);
}
-void MSCLogger::addMessageActorCreate(const std::string& source, const std::string& target) {
+void MSCLogger::addMessageActorCreate(const String& source, const String& target) {
etMutex_enter(&m_mutex);
createLine(source, " (!) ", target, "");
etMutex_leave(&m_mutex);
}
-void MSCLogger::addMessageActorDestroy(const std::string& source, const std::string& target) {
+void MSCLogger::addMessageActorDestroy(const String& source, const String& target) {
etMutex_enter(&m_mutex);
createLine(source, " (X) ", target, "");
etMutex_leave(&m_mutex);
}
-void MSCLogger::addNote(const std::string& actor, const std::string& note) {
+void MSCLogger::addNote(const String& actor, const String& note) {
etMutex_enter(&m_mutex);
//if (filter.applyTo(actor))
- getCommandList().push_back("\t" + m_filter->reduceString(actor) + " note: " + note);
+ String reduced = m_filter->reduceString(actor.c_str());
+ getCommandList().push_back("\t" + reduced + " note: " + note);
etMutex_leave(&m_mutex);
}
-void MSCLogger::addMessageCreate(const std::string& source, const std::string& target) {
+void MSCLogger::addMessageCreate(const String& source, const String& target) {
etMutex_enter(&m_mutex);
createLine(source, " (!) ", target, "");
etMutex_leave(&m_mutex);
}
-void MSCLogger::addActorState(const std::string& actor, const std::string& state) {
+void MSCLogger::addActorState(const String& actor, const String& state) {
etMutex_enter(&m_mutex);
//if (filter->applyTo(actor))
- getCommandList().push_back("\t" + m_filter->reduceString(actor) + " >>> " + state);
+ String reduced = m_filter->reduceString(actor.c_str());
+ getCommandList().push_back("\t" + reduced + " >>> " + state);
etMutex_leave(&m_mutex);
}
-void MSCLogger::addVisibleComment(const std::string& comment) {
+void MSCLogger::addVisibleComment(const String& comment) {
etMutex_enter(&m_mutex);
getCommandList().push_back("# " + comment);
etMutex_leave(&m_mutex);
}
-void MSCLogger::createLine(const std::string& source, const std::string& mid, const std::string& target,
- const std::string& message) {
+void MSCLogger::createLine(const String& source, const String& mid, const String& target,
+ const String& message) {
//if (filter->applyTo(source) && filter->applyTo(target)) {
+ String reduced_src = m_filter->reduceString(source.c_str());
+ String reduced_tgt = m_filter->reduceString(target.c_str());
getCommandList().push_back(
- "\t" + m_filter->reduceString(source) + mid + m_filter->reduceString(target) + " " + message);
+ "\t" + reduced_src + mid + reduced_tgt + " " + message);
}
void MSCLogger::close() {
if (m_is_open) {
- std::string path = m_path + m_msc_name + ".seq";
+ String path = m_path + m_msc_name + ".seq";
etFileHandle handle = etLogger_fopen(path.c_str(), "w+");
etMutex_enter(&m_mutex);
if (handle != 0) {
@@ -136,7 +138,7 @@ void MSCLogger::close() {
void MSCLogger::saveMSCforTrace2UML(etFileHandle handle) {
etLogger_fprintf(handle, "; generated MSC for Trace2UML\n");
- std::list<std::string>::iterator it = getCommandList().begin();
+ Vector<String>::iterator it = getCommandList().begin();
for (; it != getCommandList().end(); ++it){
etLogger_fprintf(handle, (*it).c_str());
etLogger_fprintf(handle, "\n");
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCLogger.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCLogger.h
index 440f20ef7..e42f32929 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCLogger.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/MSCLogger.h
@@ -14,9 +14,8 @@
#define MSCLOGGER_H_
#include "osal/etMutex.h"
-#include <iostream>
-#include <list>
-#include <string>
+#include "common/containers/String.h"
+#include "common/containers/Vector.h"
namespace etRuntime {
@@ -27,44 +26,44 @@ public:
MSCLogger();
virtual ~MSCLogger();
- void setMSC(const std::string& msc_name, const std::string& path);
+ void setMSC(const String& msc_name, const String& path);
/* synchronized */
void open();
- void addMessageAsyncOut(const std::string& source, const std::string& target, const std::string& message);
- void addMessageAsyncIn(const std::string& source, const std::string& target, const std::string& message);
- void addMessageSyncCall(const std::string& source, const std::string& target, const std::string& message);
- void addMessageSyncReturn(const std::string& source, const std::string& target, const std::string& message);
- void addMessageActorCreate(const std::string& source, const std::string& target);
- void addMessageActorDestroy(const std::string& source, const std::string& target);
- void addNote(const std::string& actor, const std::string& note);
- void addMessageCreate(const std::string& source, const std::string& target);
- void addActorState(const std::string& actor, const std::string& state);
- void addVisibleComment(const std::string& comment);
+ void addMessageAsyncOut(const String& source, const String& target, const String& message);
+ void addMessageAsyncIn(const String& source, const String& target, const String& message);
+ void addMessageSyncCall(const String& source, const String& target, const String& message);
+ void addMessageSyncReturn(const String& source, const String& target, const String& message);
+ void addMessageActorCreate(const String& source, const String& target);
+ void addMessageActorDestroy(const String& source, const String& target);
+ void addNote(const String& actor, const String& note);
+ void addMessageCreate(const String& source, const String& target);
+ void addActorState(const String& actor, const String& state);
+ void addVisibleComment(const String& comment);
void close();
/* --- */
- const std::string& getObjectName(void) { return m_objectName; }
- void setObjectName(const std::string& name) { m_objectName = name; }
+ const String& getObjectName(void) { return m_objectName; }
+ void setObjectName(const String& name) { m_objectName = name; }
- std::list<std::string>& getCommandList() { return m_commandList; };
+ Vector<String>& getCommandList() { return m_commandList; };
MSCFilter* getMSCFilter(){ return m_filter; };
private:
- void createLine(const std::string& source, const std::string& mid, const std::string& target, const std::string& message);
+ void createLine(const String& source, const String& mid, const String& target, const String& message);
void saveMSCforTrace2UML(etFileHandle handle);
- std::list<std::string> m_commandList;
+ Vector<String> m_commandList;
MSCFilter* m_filter;
- std::string m_path;
- std::string m_msc_name ;
+ String m_path;
+ String m_msc_name ;
etBool m_is_open;
etMutex m_mutex;
- std::string m_objectName;
+ String m_objectName;
MSCLogger(const MSCLogger& right);
MSCLogger& operator=(const MSCLogger& right);
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageReceiver.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageReceiver.h
index d4a8f7897..eafe6f337 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageReceiver.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageReceiver.h
@@ -16,7 +16,6 @@
#include "common/messaging/Address.h"
#include "common/messaging/IMessageReceiver.h"
#include "common/messaging/RTObject.h"
-#include <string>
namespace etRuntime {
@@ -31,12 +30,12 @@ public:
}
protected:
- AbstractMessageReceiver(IRTObject* parent, const std::string& name) :
+ AbstractMessageReceiver(IRTObject* parent, const String& name) :
RTObject(parent, name),
m_address(Address::EMPTY) {
}
- AbstractMessageReceiver(IRTObject* parent, const Address& address, const std::string& name) :
+ AbstractMessageReceiver(IRTObject* parent, const Address& address, const String& name) :
RTObject(parent, name),
m_address(address) {
}
@@ -45,7 +44,7 @@ protected:
m_address = address;
}
- virtual std::string toString() const {
+ virtual String toString() const {
return getName() + " " + m_address.toID();
}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.cpp
index 1095d71e5..cc0a66bb1 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.cpp
@@ -11,7 +11,6 @@
*******************************************************************************/
#include "common/messaging/Address.h"
-#include <string>
namespace etRuntime {
@@ -71,11 +70,11 @@ bool Address::operator<(const Address& right) const {
}
}
-std::string Address::toID() const {
+String Address::toID() const {
char buffer[50];
sprintf(buffer, "%i_%i_%i", m_nodeID, m_threadID, m_objectID);
- return std::string(buffer);
+ return String(buffer);
}
Address Address::createInc() const {
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.h
index e59228d46..0766ccc77 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Address.h
@@ -14,7 +14,7 @@
#define ADDRESS_H_
#include "etDatatypes.h"
-#include <string>
+#include "common/containers/String.h"
namespace etRuntime {
@@ -33,8 +33,8 @@ public:
bool operator!=(const Address& other) const;
bool operator< (const Address& right) const;
- std::string toString() const;
- std::string toID() const;
+ String toString() const;
+ String toID() const;
Address createInc() const;
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.cpp
index af6adef7b..00c427bde 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.cpp
@@ -11,10 +11,9 @@
*******************************************************************************/
#include "common/messaging/IRTObject.h"
-#include <string>
namespace etRuntime {
-const std::string IRTObject::NO_NAME = "<no name>";
+const String IRTObject::NO_NAME = "<no name>";
}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.h
index 4fd02181c..30225ba85 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IRTObject.h
@@ -13,8 +13,8 @@
#ifndef IRTOBJECT_H_
#define IRTOBJECT_H_
-#include <string>
-#include <vector>
+#include "common/containers/String.h"
+#include "common/containers/Vector.h"
namespace etRuntime {
@@ -26,23 +26,25 @@ public:
static const char PATH_DELIM = '/';
static const char PATHNAME_DELIM = '_';
- static const std::string NO_NAME;
+ static const String NO_NAME;
- virtual const std::string& getName() const = 0;
- virtual const std::string& getInstancePath() const = 0;
- virtual const std::string& getInstancePathName() const = 0;
+ typedef Vector<IRTObject*> ChildList;
- virtual std::vector<IRTObject*>& getChildren() = 0;
+ virtual const String& getName() const = 0;
+ virtual String getInstancePath() const = 0;
+ virtual String getInstancePathName() const = 0;
+
+ virtual ChildList& getChildren() = 0;
virtual IRTObject* getParent() const = 0;
virtual IRTObject* getRoot() const = 0;
- virtual IRTObject* getChild(const std::string& name) const = 0;
+ virtual IRTObject* getChild(const String& name) const = 0;
- virtual IRTObject* getObject(const std::string& path) const = 0;
+ virtual IRTObject* getObject(const String& path) const = 0;
- virtual int getThreadForPath(const std::string& path) const = 0;
+ virtual int getThreadForPath(const String& path) const = 0;
};
}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.cpp
index 69705f972..76cb4dbd2 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.cpp
@@ -11,8 +11,6 @@
*******************************************************************************/
#include "common/messaging/Message.h"
-#include <iostream>
-#include <string>
#include <cstring>
#include <cstdlib>
@@ -39,13 +37,20 @@ Message::~Message() {
m_dataSize = 0;
}
-std::string Message::toString() const {
- std::stringstream strm;
- strm << "Message(" << m_address.toID() << ", evt=" << m_evtId << ")";
+String Message::toString() const {
+ char buffer[50];
+
+ String result("Message(");
+ result += m_address.toID();
+ result += ", evt=";
+ sprintf(buffer, "%d", m_evtId);
+ result += buffer;
+ result += ")";
if (m_data) {
- strm << std::showbase << std::hex << m_data;
+ sprintf(buffer, "%p", m_data);
+ result += buffer;
}
- return strm.str();
+ return result;
}
} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.h
index e4564c41a..95c9350b5 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.h
@@ -15,9 +15,7 @@
#include "common/messaging/Address.h"
#include "stddef.h"
-#include <iostream>
-#include <sstream>
-#include <string>
+#include "common/containers/String.h"
namespace etRuntime {
@@ -43,7 +41,7 @@ public:
return m_data;
}
- std::string toString() const;
+ String toString() const;
protected:
friend class MessageSeQueue;
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.cpp
index f5250be98..4374c5079 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.cpp
@@ -16,7 +16,7 @@
namespace etRuntime {
-MessageDispatcher::MessageDispatcher(IRTObject* parent, const Address& addr, const std::string& name) :
+MessageDispatcher::MessageDispatcher(IRTObject* parent, const Address& addr, const String& name) :
RTObject(parent, name),
m_local_map(),
m_freeAdresses(),
@@ -29,15 +29,16 @@ MessageDispatcher::MessageDispatcher(IRTObject* parent, const Address& addr, con
Address MessageDispatcher::getFreeAddress() {
if (m_freeAdresses.empty()) {
return Address(getAddress().m_nodeID, getAddress().m_threadID, m_nextFreeObjId++);
- } else {
- Address address = m_freeAdresses.front();
- m_freeAdresses.pop();
+ }
+ else {
+ Address address = m_freeAdresses.back();
+ m_freeAdresses.pop_back();
return address;
}
}
void MessageDispatcher::freeAddress(const Address& addr) {
- m_freeAdresses.push(addr);
+ m_freeAdresses.push_back(addr);
}
void MessageDispatcher::addMessageReceiver(IMessageReceiver& receiver) {
if (!receiver.getAddress().isValid())
@@ -69,14 +70,13 @@ void MessageDispatcher::receive(const Message* msg) {
IMessageReceiver* receiver = 0;
if (msg->getAddress().m_nodeID == m_address.m_nodeID && msg->getAddress().m_threadID == m_address.m_threadID) {
- std::map<int, IMessageReceiver*>::iterator it;
- it = m_local_map.find(msg->getAddress().m_objectID);
+ Map<int, IMessageReceiver*>::iterator it = m_local_map.find(msg->getAddress().m_objectID);
if (it != m_local_map.end()) {
receiver = it->second;
}
}
if (receiver == this) {
- for (std::set<IMessageReceiver*>::iterator it = m_pollingMessageReceiver.begin();
+ for (Set<IMessageReceiver*>::iterator it = m_pollingMessageReceiver.begin();
it != m_pollingMessageReceiver.end(); ++it) {
(*it)->receive(msg);
}
@@ -89,8 +89,8 @@ void MessageDispatcher::receive(const Message* msg) {
dynamic_cast<IMessageService*>(getParent())->returnMessageBuffer(msg);
}
-std::string MessageDispatcher::toString() const {
- return getName() + " " + getAddress().toID();
+String MessageDispatcher::toString() const {
+ return getName() + " " + getAddress().toID().c_str();
}
} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.h
index 359acff43..0e2d6a9f8 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.h
@@ -13,13 +13,12 @@
#ifndef MESSAGEDISPATCHER_H_
#define MESSAGEDISPATCHER_H_
+#include "common/containers/Vector.h"
+#include "common/containers/Set.h"
+#include "common/containers/Map.h"
#include "common/messaging/Address.h"
#include "common/messaging/IMessageReceiver.h"
#include "common/messaging/RTObject.h"
-#include <map>
-#include <queue>
-#include <set>
-#include <string>
@@ -27,7 +26,7 @@ namespace etRuntime {
class MessageDispatcher : public RTObject, public virtual IMessageReceiver {
public:
- MessageDispatcher(IRTObject* parent, const Address& addr, const std::string& name);
+ MessageDispatcher(IRTObject* parent, const Address& addr, const String& name);
virtual ~MessageDispatcher() {}
Address getFreeAddress();
@@ -41,12 +40,12 @@ class MessageDispatcher : public RTObject, public virtual IMessageReceiver {
const Address& getAddress() const { return m_address; };
protected:
- std::string toString() const;
+ String toString() const;
private:
- std::map<int, IMessageReceiver*> m_local_map;
- std::queue<Address> m_freeAdresses;
- std::set<IMessageReceiver*> m_pollingMessageReceiver;
+ Map<int, IMessageReceiver*> m_local_map;
+ Vector<Address> m_freeAdresses;
+ Set<IMessageReceiver*> m_pollingMessageReceiver;
Address m_address;
int m_nextFreeObjId;
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.cpp
index 05acc694d..70bb49da5 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.cpp
@@ -14,7 +14,7 @@
namespace etRuntime {
-MessageSeQueue::MessageSeQueue(IRTObject* parent, const std::string& name)
+MessageSeQueue::MessageSeQueue(IRTObject* parent, const String& name)
: RTObject(parent, name),
m_first(0),
m_last(0),
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.h
index e2b42e67f..f19023308 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageSeQueue.h
@@ -16,13 +16,12 @@
#include "common/messaging/RTObject.h"
#include "common/messaging/Message.h"
#include "etDatatypes.h"
-#include <string>
namespace etRuntime {
class MessageSeQueue: public RTObject {
public:
- MessageSeQueue(IRTObject* parent, const std::string& name);
+ MessageSeQueue(IRTObject* parent, const String& name);
virtual ~MessageSeQueue();
void push(Message* msg);
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp
index 62d62d66f..4b4e13fba 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp
@@ -15,12 +15,12 @@
#include "common/messaging/MessageServiceController.h"
#include "common/messaging/RTServices.h"
#include "osal/etTime.h"
-#include <string>
+#include <new>
namespace etRuntime {
-MessageService::MessageService(IRTObject* parent, IMessageService::ExecMode mode, int node, int thread, const std::string& name,
+MessageService::MessageService(IRTObject* parent, IMessageService::ExecMode mode, int node, int thread, const String& name,
IMessageMemory* memory, int priority) :
RTObject(parent, name),
m_running(false),
@@ -38,7 +38,7 @@ MessageService::MessageService(IRTObject* parent, IMessageService::ExecMode mode
}
MessageService::MessageService(IRTObject* parent, IMessageService::ExecMode mode, etTime interval, int node, int thread,
- const std::string& name, IMessageMemory* memory, int priority) :
+ const String& name, IMessageMemory* memory, int priority) :
RTObject(parent, name),
m_running(false),
m_execMode(mode),
@@ -173,8 +173,8 @@ void MessageService::returnMessageBuffer(const Message* buffer) {
etMutex_leave(&m_mutex);
}
-std::string MessageService::toString() const {
- return getName() + " " + getAddress().toID();
+String MessageService::toString() const {
+ return getName() + " " + getAddress().toID().c_str();
}
void MessageService::terminate() {
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.h
index 388226079..6afd3524c 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.h
@@ -23,7 +23,6 @@
#include "osal/etSema.h"
#include "osal/etThread.h"
#include "osal/etTimer.h"
-#include <string>
namespace etRuntime {
@@ -35,8 +34,8 @@ public:
POLLED, BLOCKED, MIXED
};
- MessageService(IRTObject* parent, IMessageService::ExecMode mode, int node, int thread, const std::string& name, IMessageMemory* memory, int priority = 0);
- MessageService(IRTObject* parent, IMessageService::ExecMode mode, etTime interval, int node, int thread, const std::string& name, IMessageMemory* memory, int priority = 0);
+ MessageService(IRTObject* parent, IMessageService::ExecMode mode, int node, int thread, const String& name, IMessageMemory* memory, int priority = 0);
+ MessageService(IRTObject* parent, IMessageService::ExecMode mode, etTime interval, int node, int thread, const String& name, IMessageMemory* memory, int priority = 0);
virtual ~MessageService();
void run();
@@ -59,7 +58,7 @@ public:
void returnMessageBuffer(const Message* buffer);
const Address& getAddress(void) const { return m_address; }
- std::string toString() const;
+ String toString() const;
protected:
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp
index 7ac21eb4e..a5697e2ae 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp
@@ -10,12 +10,22 @@
*
*******************************************************************************/
-#include <algorithm>
-
#include "MessageServiceController.h"
+#include "common/containers/String.h"
namespace etRuntime {
+typedef Vector<IMessageService*>::iterator iterator;
+static iterator find(iterator begin, iterator end, const IMessageService* value) {
+ iterator current = begin;
+ for (; current!=end; ++current) {
+ if (*current==value) {
+ return current;
+ }
+ }
+ return current;
+}
+
MessageServiceController::MessageServiceController() :
m_messageServices(),
m_freeIDs(),
@@ -33,7 +43,7 @@ int MessageServiceController::getNewID() {
newID = m_nextFreeID++;
else {
newID = m_freeIDs.back();
- m_freeIDs.pop();
+ m_freeIDs.pop_back();
}
etMutex_leave(&m_mutex);
@@ -42,7 +52,7 @@ int MessageServiceController::getNewID() {
void MessageServiceController::freeID(int id) {
etMutex_enter(&m_mutex);
- m_freeIDs.push(id);
+ m_freeIDs.push_back(id);
etMutex_leave(&m_mutex);
}
@@ -58,7 +68,7 @@ void MessageServiceController::addMsgSvc(IMessageService& msgSvc) {
void MessageServiceController::removeMsgSvc(IMessageService& msgSvc) {
etMutex_enter(&m_mutex);
- MsgSvcList::iterator it = std::find(m_messageServices.begin(), m_messageServices.end(), &msgSvc);
+ MsgSvcList::iterator it = find(m_messageServices.begin(), m_messageServices.end(), &msgSvc);
if (it!=m_messageServices.end()) {
m_messageServices.erase(it);
}
@@ -98,7 +108,7 @@ void MessageServiceController::stop() {
m_running = false;
}
-void MessageServiceController::dumpThreads(std::string msg) {
+void MessageServiceController::dumpThreads(String msg) {
// std::cout << "<<< begin dump threads <<<" << std::endl;
// std::cout << "=== " << msg << std::endl;
//TODO dump stack traces
@@ -146,7 +156,7 @@ void MessageServiceController::resetAll() {
etMutex_enter(&m_mutex);
m_messageServices.clear();
while (!m_freeIDs.empty()) {
- m_freeIDs.pop();
+ m_freeIDs.pop_back();
}
m_nextFreeID = 0;
etMutex_leave(&m_mutex);
@@ -154,7 +164,7 @@ void MessageServiceController::resetAll() {
void MessageServiceController::setMsgSvcTerminated(const IMessageService& msgSvc){
etMutex_enter(&m_mutex);
- MsgSvcList::iterator it = std::find(m_terminateServices.begin(), m_terminateServices.end(), &msgSvc);
+ MsgSvcList::iterator it = find(m_terminateServices.begin(), m_terminateServices.end(), &msgSvc);
if (it!=m_terminateServices.end()) {
m_terminateServices.erase(it);
}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h
index c9bc85aed..bd15af6f5 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h
@@ -14,11 +14,9 @@
#define MESSAGESERVICECONTROLLER_H_
#include "common/messaging/IMessageService.h"
+#include "common/containers/Vector.h"
#include "osal/etMutex.h"
#include "osal/etSema.h"
-#include <vector>
-#include <queue>
-#include <string>
namespace etRuntime {
@@ -45,15 +43,15 @@ public:
void setMsgSvcTerminated(const IMessageService& msgSvc);
protected:
- void dumpThreads(std::string msg);
+ void dumpThreads(String msg);
private:
void terminate();
- typedef std::vector<IMessageService*> MsgSvcList;
+ typedef Vector<IMessageService*> MsgSvcList;
MsgSvcList m_messageServices;
- std::queue<int> m_freeIDs;
+ Vector<int> m_freeIDs;
etBool m_running;
int m_nextFreeID;
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.cpp
index 6c3182ecc..4a4692c67 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.cpp
@@ -12,29 +12,31 @@
#include "common/messaging/RTObject.h"
#include "etDatatypes.h"
-#include <iterator>
-#include <string>
-#include <vector>
namespace etRuntime {
-RTObject::RTObject(IRTObject* parent, const std::string& name) :
+RTObject::RTObject(IRTObject* parent, const String& name) :
m_name(name),
m_parent(parent),
m_children() {
if (m_parent != 0) {
m_parent->getChildren().push_back(this);
+#ifdef RTOBJECT_STORES_PATHS
m_instancePath = m_parent->getInstancePath() + PATH_DELIM + m_name;
m_instancePathName = m_parent->getInstancePathName() + PATHNAME_DELIM + m_name;
- } else {
+#endif
+ }
+#ifdef RTOBJECT_STORES_PATHS
+ else {
m_instancePath = PATH_DELIM + m_name;
m_instancePathName = PATHNAME_DELIM + m_name;
}
+#endif
}
void RTObject::destroy() {
- for (std::vector<IRTObject*>::iterator it = m_children.begin(); it != m_children.end(); ++it) {
+ for (ChildList::iterator it = m_children.begin(); it != m_children.end(); ++it) {
RTObject* child = dynamic_cast<RTObject*>(*it);
if (child != 0) {
child->destroy();
@@ -53,8 +55,8 @@ IRTObject* RTObject::getRoot() const {
return root;
}
-IRTObject* RTObject::getChild(const std::string& name) const {
- for (std::vector<IRTObject*>::const_iterator it = m_children.begin(); it != m_children.end(); ++it) {
+IRTObject* RTObject::getChild(const String& name) const {
+ for (ChildList::const_iterator it = m_children.begin(); it != m_children.end(); ++it) {
if (name == ((*it)->getName())) {
return *it;
}
@@ -63,17 +65,17 @@ IRTObject* RTObject::getChild(const std::string& name) const {
return 0;
}
-IRTObject* RTObject::getObject(const std::string& path) const {
+IRTObject* RTObject::getObject(const String& path) const {
etBool isAbsolute = (path[0] == PATH_DELIM);
if (isAbsolute && getParent() != 0)
return getParent()->getObject(path);
- std::string segment;
+ String segment;
std::size_t last = 0;
if (isAbsolute) {
last = 1;
size_t first = path.find(PATH_DELIM, last);
- segment = path.substr(last, (first == std::string::npos) ? std::string::npos : first - 1);
+ segment = path.substr(last, (first == String::npos) ? String::npos : first - 1);
if (segment != m_name)
return 0;
@@ -82,7 +84,7 @@ IRTObject* RTObject::getObject(const std::string& path) const {
IRTObject* current = const_cast<RTObject*>(this);
std::size_t next;
- while ((next = path.find(PATH_DELIM, last)) != std::string::npos) {
+ while ((next = path.find(PATH_DELIM, last)) != String::npos) {
if (next > last + 1) {
segment = path.substr(last, next - last);
current = current->getChild(segment);
@@ -99,18 +101,18 @@ IRTObject* RTObject::getObject(const std::string& path) const {
return current;
}
-int RTObject::getThreadForPath(const std::string& path) const {
+int RTObject::getThreadForPath(const String& path) const {
if (m_parent != 0)
return m_parent->getThreadForPath(path);
return -1;
}
-std::string RTObject::toStringRecursive(const std::string& indent) const {
- std::string result(indent + toString() + "\n");
+String RTObject::toStringRecursive(const String& indent) const {
+ String result(indent + toString() + "\n");
- std::string indentInc(" " + indent);
- std::vector<IRTObject*>::const_iterator it = m_children.begin();
+ String indentInc(" " + indent);
+ ChildList::const_iterator it = m_children.begin();
for (; it != m_children.end(); ++it) {
RTObject* child = dynamic_cast<RTObject*>(*it);
if (child != 0)
@@ -120,11 +122,31 @@ std::string RTObject::toStringRecursive(const std::string& indent) const {
return result;
}
-std::string RTObject::toStringRecursive() const {
+#ifndef RTOBJECT_STORES_PATHS
+String RTObject::getInstancePath() const {
+ if (m_parent != 0) {
+ return m_parent->getInstancePath() + PATH_DELIM + m_name;
+ }
+ else {
+ return PATH_DELIM + m_name;
+ }
+}
+
+String RTObject::getInstancePathName() const {
+ if (m_parent != 0) {
+ return m_parent->getInstancePathName() + PATHNAME_DELIM + m_name;
+ }
+ else {
+ return PATHNAME_DELIM + m_name;
+ }
+}
+#endif
+
+String RTObject::toStringRecursive() const {
return toStringRecursive("");
}
-std::string RTObject::toString() const {
+String RTObject::toString() const {
return getName();
}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.h
index ceb2b6c93..5de8f1344 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTObject.h
@@ -14,28 +14,22 @@
#define RTOBJECT_H_
#include "common/messaging/IRTObject.h"
-#include <string>
-#include <vector>
namespace etRuntime {
class RTObject: public virtual IRTObject {
public:
- RTObject(IRTObject* parent, const std::string& name);
+ RTObject(IRTObject* parent, const String& name);
virtual ~RTObject() {}
- virtual const std::string& getName() const {
+ virtual const String& getName() const {
return m_name;
}
- virtual const std::string& getInstancePath() const {
- return m_instancePath;
- }
- virtual const std::string& getInstancePathName() const {
- return m_instancePathName;
- }
+ virtual String getInstancePath() const;
+ virtual String getInstancePathName() const;
- virtual std::vector<IRTObject*>& getChildren() {
+ virtual ChildList& getChildren() {
return m_children;
}
@@ -45,33 +39,47 @@ public:
virtual IRTObject* getRoot() const;
- virtual IRTObject* getChild(const std::string& name) const;
+ virtual IRTObject* getChild(const String& name) const;
- virtual IRTObject* getObject(const std::string& path) const;
+ virtual IRTObject* getObject(const String& path) const;
- virtual int getThreadForPath(const std::string& path) const;
+ virtual int getThreadForPath(const String& path) const;
protected:
virtual void destroy();
- std::string toStringRecursive(const std::string& indent) const;
- std::string toStringRecursive() const;
- virtual std::string toString() const;
+ String toStringRecursive(const String& indent) const;
+ String toStringRecursive() const;
+ virtual String toString() const;
private:
- std::string m_name;
- // for speed optimization the instance paths are created at instantiation
- // and used as const ref parameters in the logging methods to avoid copying
- std::string m_instancePath;
- std::string m_instancePathName;
+ String m_name;
IRTObject* m_parent;
- std::vector<IRTObject*> m_children;
-
+ ChildList m_children;
+#ifdef RTOBJECT_STORES_PATHS
+ // for speed optimization the instance paths are created at instantiation
+ // TODO: if not RTOBJECT_STORES_PATHS we need to return a copy
+ // in the other case it would be more efficient to return const refs.
+ // Can this be resolved in some way?
+ String m_instancePath;
+ String m_instancePathName;
+#endif
+
+ // unimplemented
RTObject();
RTObject(RTObject const&);
RTObject& operator=(RTObject const&);
};
+#ifdef RTOBJECT_STORES_PATHS
+inline const String& RTObject::getInstancePath() const {
+ return m_instancePath;
+}
+inline const String& RTObject::getInstancePathName() const {
+ return m_instancePathName;
+}
+#endif
+
} /* namespace etRuntime */
#endif /* RTOBJECT_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/StaticMessageMemory.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/StaticMessageMemory.cpp
index d88f10b86..c92b01d90 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/StaticMessageMemory.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/StaticMessageMemory.cpp
@@ -11,10 +11,11 @@
*******************************************************************************/
#include "common/messaging/StaticMessageMemory.h"
+#include <new>
namespace etRuntime {
-StaticMessageMemory::StaticMessageMemory(IRTObject* parent, const std::string& name, size_t size, int number) :
+StaticMessageMemory::StaticMessageMemory(IRTObject* parent, const String& name, size_t size, int number) :
RTObject(parent, name), m_size(size), m_msgPool(NULL, "memory"), m_buffer(0) {
m_buffer = new uint8_t[m_size * number];
uint8_t* ptr = m_buffer;
@@ -31,10 +32,10 @@ StaticMessageMemory::~StaticMessageMemory() {
Message* StaticMessageMemory::getMessageBuffer(size_t size) {
if(size > m_size) {
- std::cout << "Could not provide message buffer (message too big)!" << std::endl;
+ printf("Could not provide message buffer (message too big)!\n");
}
else if(m_msgPool.getSize() <= 0) {
- std::cout << "Could not provide message buffer (message pool is empty)!" << std::endl;
+ printf("Could not provide message buffer (message pool is empty)!\n");
}
else {
return const_cast<Message*>(m_msgPool.pop());
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/StaticMessageMemory.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/StaticMessageMemory.h
index 56b5eabb1..b2df0adcc 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/StaticMessageMemory.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/StaticMessageMemory.h
@@ -21,7 +21,7 @@ namespace etRuntime {
class StaticMessageMemory : public IMessageMemory, public RTObject {
public:
- StaticMessageMemory(IRTObject* parent, const std::string& name, size_t size, int number);
+ StaticMessageMemory(IRTObject* parent, const String& name, size_t size, int number);
virtual ~StaticMessageMemory();
// returns a buffer of the specified size in bytes
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp
index 5f67b8ac5..4884bac09 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp
@@ -15,14 +15,11 @@
#include "common/modelbase/RTSystemServicesProtocol.h"
#include "common/modelbase/SystemPortOwner.h"
#include "etDatatypes.h"
-#include <iterator>
-#include <string>
-#include <vector>
namespace etRuntime {
-ActorClassBase::ActorClassBase(IRTObject* parent, const std::string& name) :
+ActorClassBase::ActorClassBase(IRTObject* parent, const String& name) :
SystemPortOwner(parent, name),
m_state(0),
m_RTSystemPort(this, IFITEM_RTSystemPort),
@@ -51,7 +48,7 @@ void ActorClassBase::initialize() {
//--------------------- life cycle functions
void ActorClassBase::init() {
ActorClassBase* child = 0;
- for (std::vector<IRTObject*>::iterator it = getChildren().begin(); it != getChildren().end(); ++it) {
+ for (ChildList::iterator it = getChildren().begin(); it != getChildren().end(); ++it) {
if ((child = dynamic_cast<ActorClassBase*>(*it)) != 0)
child->init();
}
@@ -61,7 +58,7 @@ void ActorClassBase::init() {
void ActorClassBase::start() {
ActorClassBase* child = 0;
- for (std::vector<IRTObject*>::iterator it = getChildren().begin(); it != getChildren().end(); ++it) {
+ for (ChildList::iterator it = getChildren().begin(); it != getChildren().end(); ++it) {
if ((child = dynamic_cast<ActorClassBase*>(*it)) != 0)
child->start();
}
@@ -73,7 +70,7 @@ void ActorClassBase::stop() {
stopUser();
ActorClassBase* child = 0;
- for (std::vector<IRTObject*>::iterator it = getChildren().begin(); it != getChildren().end(); ++it) {
+ for (ChildList::iterator it = getChildren().begin(); it != getChildren().end(); ++it) {
if ((child = dynamic_cast<ActorClassBase*>(*it)) != 0)
child->stop();
}
@@ -102,7 +99,7 @@ etBool ActorClassBase::handleSystemEvent(InterfaceItemBase* ifitem, int evt, voi
return true;
}
-std::string ActorClassBase::toString() const {
+String ActorClassBase::toString() const {
ActorClassBase* thisPtr = const_cast<ActorClassBase*>(this);
char buffer[10];
sprintf(buffer, "%i", thisPtr->getThread());
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h
index 52d876b17..9c4ca8485 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h
@@ -18,7 +18,6 @@
#include "common/modelbase/RTSystemProtocol.h"
#include "common/modelbase/SystemPortOwner.h"
#include "etDatatypes.h"
-#include <string>
namespace etRuntime {
@@ -28,11 +27,11 @@ public:
virtual ~ActorClassBase();
- const std::string& getClassName() const {
+ const String& getClassName() const {
return m_className;
}
- void setClassName(const std::string& className) {
+ void setClassName(const String& className) {
m_className = className;
}
@@ -72,7 +71,7 @@ public:
protected:
- ActorClassBase(IRTObject* parent, const std::string&);
+ 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;
@@ -88,9 +87,9 @@ protected:
RTSystemPort m_RTSystemPort;
virtual etBool handleSystemEvent(InterfaceItemBase* ifitem, int evt, void* generic_data);
- std::string toString() const;
+ String toString() const;
private:
- std::string m_className;
+ String m_className;
ActorClassBase();
ActorClassBase(ActorClassBase const&);
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/DataPort.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/DataPort.cpp
index 5726012ac..42d6f3dec 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/DataPort.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/DataPort.cpp
@@ -11,11 +11,10 @@
*******************************************************************************/
#include "common/modelbase/DataPort.h"
-#include <string>
namespace etRuntime {
-void DataPortBase::connect(IRTObject* obj, const std::string& path1, const std::string& path2) {
+void DataPortBase::connect(IRTObject* obj, const String& path1, const String& path2) {
IRTObject* obj1 = obj->getObject(path1);
IRTObject* obj2 = obj->getObject(path2);
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/DataPort.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/DataPort.h
index eac2b6b21..1cb3de715 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/DataPort.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/DataPort.h
@@ -13,15 +13,14 @@
#define SRC_COMMON_MODELBASE_DATAPORT_H_
#include "common/messaging/RTObject.h"
-#include <string>
namespace etRuntime {
class DataPortBase: public RTObject {
public:
- static void connect(IRTObject* obj, const std::string& path1, const std::string& path2);
+ static void connect(IRTObject* obj, const String& path1, const String& path2);
- DataPortBase(IRTObject* parent, const std::string& name, int localId) :
+ DataPortBase(IRTObject* parent, const String& name, int localId) :
RTObject(parent, name),
m_localId(localId) {
}
@@ -40,7 +39,7 @@ private:
class DataSendPort: public DataPortBase {
public:
- DataSendPort(IRTObject* parent, const std::string& name, int localId) :
+ DataSendPort(IRTObject* parent, const String& name, int localId) :
DataPortBase(parent, name, localId) {
}
@@ -53,7 +52,7 @@ private:
class DataReceivePort: public DataPortBase {
friend class DataPortBase;
public:
- DataReceivePort(IRTObject* parent, const std::string& name, int localId) :
+ DataReceivePort(IRTObject* parent, const String& name, int localId) :
DataPortBase(parent, name, localId) {
}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.cpp
index 9ca651026..4c6829b44 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.cpp
@@ -11,11 +11,10 @@
*******************************************************************************/
#include "common/modelbase/EventReceiver.h"
-#include <string>
namespace etRuntime {
-EventReceiver::EventReceiver(IRTObject* parent, const std::string& name) :
+EventReceiver::EventReceiver(IRTObject* parent, const String& name) :
RTObject(parent, name),
m_thread(-1) {
}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.h
index e67df44b9..cfdb7c230 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/EventReceiver.h
@@ -15,7 +15,6 @@
#include "common/messaging/RTObject.h"
#include "common/modelbase/IEventReceiver.h"
-#include <string>
namespace etRuntime {
@@ -27,7 +26,7 @@ public:
virtual int getThread();
protected:
- EventReceiver(IRTObject* parent, const std::string& name);
+ EventReceiver(IRTObject* parent, const String& name);
private:
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.cpp
index 498137c69..0e45bc4de 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.cpp
@@ -17,11 +17,10 @@
#include "common/modelbase/IInterfaceItemOwner.h"
#include "common/modelbase/InterfaceItemBase.h"
#include "common/modelbase/IReplicatedInterfaceItem.h"
-#include <string>
namespace etRuntime {
-void InterfaceItemBase::connect(IRTObject* obj, const std::string& path1, const std::string& path2) {
+void InterfaceItemBase::connect(IRTObject* obj, const String& path1, const String& path2) {
IRTObject* obj1 = obj->getObject(path1);
IRTObject* obj2 = obj->getObject(path2);
@@ -33,7 +32,7 @@ void InterfaceItemBase::connect(IRTObject* obj, const std::string& path1, const
}
}
-InterfaceItemBase::InterfaceItemBase(IInterfaceItemOwner* owner, const std::string& name, int localId, int idx) :
+InterfaceItemBase::InterfaceItemBase(IInterfaceItemOwner* owner, const String& name, int localId, int idx) :
AbstractMessageReceiver(owner->getEventReceiver(), name),
m_localId(localId),
m_idx(idx),
@@ -135,20 +134,19 @@ void InterfaceItemBase::destroy() {
AbstractMessageReceiver::destroy();
}
-std::string InterfaceItemBase::toString() const {
- std::stringstream result;
-
- result << ((m_replicator != 0) ? "sub " : "");
- result << "port " + getName() << " " << getAddress().toID() << " ";
- if(m_peerMsgReceiver == 0)
- result << "UNCONNECTED";
+String InterfaceItemBase::toString() const {
+ char buffer [256];
+ const char* sub = (m_replicator != 0) ? "sub " : "";
+ int pos = sprintf(buffer, "%sport %s %s ", sub, getName().c_str(), getAddress().toID().c_str());
+ if (m_peerMsgReceiver == 0) {
+ sprintf(buffer+pos, "UNCONNECTED");
+ }
else {
- result << " -> ";
- result << ((m_peer != 0) ? m_peer->getName() : "?");
- result << " " << m_peerAddress.toID();
+ const char* peerName = (m_peer != 0) ? m_peer->getName().c_str() : "?";
+ sprintf(buffer + pos, " -> %s %s", peerName, m_peerAddress.toID().c_str());
}
- return result.str();
+ return buffer;
}
} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.h
index cdb12d99d..004cb129d 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.h
@@ -17,7 +17,6 @@
#include "common/messaging/Address.h"
#include "common/messaging/IMessageService.h"
#include "common/modelbase/IInterfaceItem.h"
-#include <string>
namespace etRuntime {
@@ -28,7 +27,7 @@ class IMessageService;
class InterfaceItemBase: public AbstractMessageReceiver, public virtual IInterfaceItem {
public:
- static void connect(IRTObject* obj, const std::string& path1, const std::string& path2);
+ static void connect(IRTObject* obj, const String& path1, const String& path2);
virtual ~InterfaceItemBase();
@@ -45,9 +44,9 @@ public:
IEventReceiver* getActor() const;
- virtual std::string toString() const;
+ virtual String toString() const;
protected:
- InterfaceItemBase(IInterfaceItemOwner* owner, const std::string& name, int localId, int idx);
+ InterfaceItemBase(IInterfaceItemOwner* owner, const String& name, int localId, int idx);
IMessageReceiver* getMsgReceiver() const {
return m_ownMsgReceiver;
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.h
index 9fbb2c1be..8be912354 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/PortBase.h
@@ -15,7 +15,6 @@
#include "common/modelbase/IInterfaceItemOwner.h"
#include "common/modelbase/InterfaceItemBase.h"
-#include <string>
namespace etRuntime {
@@ -25,11 +24,11 @@ public:
virtual ~PortBase() {}
protected:
- PortBase(IInterfaceItemOwner* owner, const std::string& name, int localId) :
+ PortBase(IInterfaceItemOwner* owner, const String& name, int localId) :
InterfaceItemBase(owner, name, localId, 0) {
}
- PortBase(IInterfaceItemOwner* owner, const std::string& name, int localId, int idx) :
+ PortBase(IInterfaceItemOwner* owner, const String& name, int localId, int idx) :
InterfaceItemBase(owner, name, localId, idx) {
}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/RTSystem.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/RTSystem.h
index 4dbae420c..afee89e71 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/RTSystem.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/RTSystem.h
@@ -13,14 +13,14 @@
#define SRC_COMMON_MODELBASE_RTSYSTEM_H_
#include "common/messaging/RTObject.h"
-#include <string>
+#include "common/containers/String.h"
namespace etRuntime {
class RTSystem: public RTObject {
public:
- explicit RTSystem(std::string name) :
+ explicit RTSystem(String name) :
RTObject(0, name) {
}
virtual ~RTSystem() {}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/RTSystemProtocol.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/RTSystemProtocol.cpp
index 9a9f930b0..eaf8ec682 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/RTSystemProtocol.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/RTSystemProtocol.cpp
@@ -12,26 +12,25 @@
#include "common/modelbase/IEventReceiver.h"
#include "common/modelbase/RTSystemProtocol.h"
-#include <string>
namespace etRuntime {
-const std::string RTSystemProtocol::RT_SYSTEM_PORT_NAME = "RTSystemPort";
+const String RTSystemProtocol::RT_SYSTEM_PORT_NAME = "RTSystemPort";
RTSystemPort::RTSystemPort(IInterfaceItemOwner* actor, int localId) :
- RTSystemServicesProtocolPort(actor, RTSystemProtocol::RT_SYSTEM_PORT_NAME, localId) {
+ RTSystemServicesProtocolPort(actor, RTSystemProtocol::RT_SYSTEM_PORT_NAME.c_str(), localId) {
}
RTSystemConjPort::RTSystemConjPort(IInterfaceItemOwner* actor, int localId) :
- RTSystemServicesProtocolConjReplPort(actor, RTSystemProtocol::RT_SYSTEM_PORT_NAME, localId) {
+ RTSystemServicesProtocolConjReplPort(actor, RTSystemProtocol::RT_SYSTEM_PORT_NAME.c_str(), localId) {
}
-InterfaceItemBase* RTSystemConjPort::createInterfaceItem(IInterfaceItemOwner* rcv, const std::string& name, int lid, int idx) {
+InterfaceItemBase* RTSystemConjPort::createInterfaceItem(IInterfaceItemOwner* rcv, const String& name, int lid, int idx) {
return new RTSystemConjSubPort(rcv, name, lid, idx);
}
-RTSystemConjSubPort::RTSystemConjSubPort(IInterfaceItemOwner* actor, const std::string& name, int localId, int idx) :
- RTSystemServicesProtocolConjPort(actor, name, localId, idx) {
+RTSystemConjSubPort::RTSystemConjSubPort(IInterfaceItemOwner* actor, const String& name, int localId, int idx) :
+ RTSystemServicesProtocolConjPort(actor, name.c_str(), localId, idx) {
}
} // namespace etRuntime
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/RTSystemProtocol.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/RTSystemProtocol.h
index 61f0b8665..0536d2102 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/RTSystemProtocol.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/RTSystemProtocol.h
@@ -9,13 +9,12 @@
#define SRC_COMMON_MESSAGING_RTSYSTEMPROTOCOL_H_
#include "common/modelbase/RTSystemServicesProtocol.h"
-#include <string>
namespace etRuntime {
class RTSystemProtocol {
public:
- static const std::string RT_SYSTEM_PORT_NAME;
+ static const String RT_SYSTEM_PORT_NAME;
};
@@ -37,7 +36,7 @@ public:
virtual ~RTSystemConjPort() {}
protected:
- virtual InterfaceItemBase* createInterfaceItem(IInterfaceItemOwner* rcv, const std::string& name, int lid, int idx);
+ virtual InterfaceItemBase* createInterfaceItem(IInterfaceItemOwner* rcv, const String& name, int lid, int idx);
private:
RTSystemConjPort();
@@ -47,7 +46,7 @@ private:
class RTSystemConjSubPort: public RTSystemServicesProtocolConjPort {
public:
- RTSystemConjSubPort(IInterfaceItemOwner* actor, const std::string& name, int localId, int idx);
+ RTSystemConjSubPort(IInterfaceItemOwner* actor, const String& name, int localId, int idx);
virtual ~RTSystemConjSubPort() {}
private:
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedActorClassBase.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedActorClassBase.cpp
index fc9747cc0..923a327eb 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedActorClassBase.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedActorClassBase.cpp
@@ -14,33 +14,35 @@
namespace etRuntime {
-ReplicatedActorClassBase::ReplicatedActorClassBase(IRTObject* parent, const std::string& name) :
+ReplicatedActorClassBase::ReplicatedActorClassBase(IRTObject* parent, const String& name) :
RTObject(parent, name), m_items() {
}
ReplicatedActorClassBase::~ReplicatedActorClassBase() {
- for(std::vector<ActorClassBase*>::iterator it = m_items.begin(); it != m_items.end(); ++it) {
+ for(Vector<ActorClassBase*>::iterator it = m_items.begin(); it != m_items.end(); ++it) {
delete *it;
}
}
void ReplicatedActorClassBase::createSubActors(int number) {
+ m_items.reserve(m_items.size() + number);
+
for (int i = 0; i < number; i++) {
- std::stringstream itemName;
- itemName << getName() << SEP << i;
- ActorClassBase* item = createActor(getParent(), itemName.str());
+ char buffer[64];
+ sprintf(buffer, "%s%c%d", getName().c_str(), SEP, i);
+ ActorClassBase* item = createActor(getParent(), buffer);
m_items.push_back(item);
}
}
void ReplicatedActorClassBase::initialize() {
- for(std::vector<ActorClassBase*>::iterator it = m_items.begin(); it != m_items.end(); ++it) {
+ for(Vector<ActorClassBase*>::iterator it = m_items.begin(); it != m_items.end(); ++it) {
(*it)->initialize();
}
}
void ReplicatedActorClassBase::setProbesActive(bool recursive, bool active) {
- for(std::vector<ActorClassBase*>::iterator it = m_items.begin(); it != m_items.end(); ++it)
+ for(Vector<ActorClassBase*>::iterator it = m_items.begin(); it != m_items.end(); ++it)
(*it)->setProbesActive(recursive, active);
}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedActorClassBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedActorClassBase.h
index 6a1eba38d..b4eb3b0bf 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedActorClassBase.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedActorClassBase.h
@@ -15,6 +15,8 @@
#include "common/messaging/RTObject.h"
#include "common/modelbase/ActorClassBase.h"
+#include "common/containers/String.h"
+#include "common/containers/Vector.h"
namespace etRuntime {
@@ -23,19 +25,19 @@ class ReplicatedActorClassBase : public RTObject {
public:
static const char SEP = ':';
- ReplicatedActorClassBase(IRTObject* parent, const std::string& name);
+ ReplicatedActorClassBase(IRTObject* parent, const String& name);
virtual ~ReplicatedActorClassBase(void);
void createSubActors(int number);
void initialize(void);
void setProbesActive(bool recursive, bool active);
int getNSubActors(void) { return m_items.size(); }
- ActorClassBase* getSubActor(int index) { return m_items.at(index); }
+ ActorClassBase* getSubActor(int index) { return m_items[index]; }
protected:
- virtual ActorClassBase* createActor(IRTObject* parent, const std::string& name) = 0;
+ virtual ActorClassBase* createActor(IRTObject* parent, const String& name) = 0;
private:
- std::vector<ActorClassBase*> m_items;
+ Vector<ActorClassBase*> m_items;
};
} // namespace et Runtime
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedInterfaceItemBase.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedInterfaceItemBase.cpp
index 6e5b536d2..c89d87137 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedInterfaceItemBase.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedInterfaceItemBase.cpp
@@ -13,14 +13,10 @@
#include "common/messaging/RTObject.h"
#include "common/modelbase/IEventReceiver.h"
#include "common/modelbase/ReplicatedInterfaceItemBase.h"
-#include <iterator>
-#include <queue>
-#include <string>
-#include <vector>
namespace etRuntime {
-ReplicatedInterfaceItemBase::ReplicatedInterfaceItemBase(IInterfaceItemOwner* owner, const std::string& name, int localId) :
+ReplicatedInterfaceItemBase::ReplicatedInterfaceItemBase(IInterfaceItemOwner* owner, const String& name, int localId) :
RTObject(owner, name),
m_localId(localId),
m_items(),
@@ -28,29 +24,29 @@ ReplicatedInterfaceItemBase::ReplicatedInterfaceItemBase(IInterfaceItemOwner* ow
}
ReplicatedInterfaceItemBase::~ReplicatedInterfaceItemBase() {
- for(std::vector<InterfaceItemBase*>::iterator it = m_items.begin(); it != m_items.end(); ++it) {
+ for(Vector<InterfaceItemBase*>::iterator it = m_items.begin(); it != m_items.end(); ++it) {
delete *it;
}
}
InterfaceItemBase* ReplicatedInterfaceItemBase::createSubInterfaceItem() {
int newIndex = getFreeIndex();
- std::stringstream itemName;
- itemName << getName() << SEP << newIndex;
+ char buffer[64];
+ sprintf(buffer, "%s%c%d", getName().c_str(), SEP, newIndex);
- InterfaceItemBase* item = createInterfaceItem(this, itemName.str(), m_localId, newIndex);
+ InterfaceItemBase* item = createInterfaceItem(this, buffer, m_localId, newIndex);
m_items.push_back(item);
return item;
}
void ReplicatedInterfaceItemBase::removeItem(InterfaceItemBase& item) {
- std::vector<InterfaceItemBase*>::iterator it = m_items.begin();
+ Vector<InterfaceItemBase*>::iterator it = m_items.begin();
while (it != m_items.end() && *it != &item) {
++it;
}
if (it != m_items.end()) {
m_items.erase(it);
- m_releasedIndices.push(item.getIdx());
+ m_releasedIndices.push_back(item.getIdx());
}
}
@@ -59,14 +55,14 @@ int ReplicatedInterfaceItemBase::getFreeIndex() {
return m_items.size();
else {
int idx = m_releasedIndices.front();
- m_releasedIndices.pop();
+ m_releasedIndices.pop_back();
return idx;
}
}
InterfaceItemBase* ReplicatedInterfaceItemBase::getInterfaceItem(int idx) const {
- for (std::vector<InterfaceItemBase*>::const_iterator it = m_items.begin(); it != m_items.end(); ++it) {
+ for (Vector<InterfaceItemBase*>::const_iterator it = m_items.begin(); it != m_items.end(); ++it) {
if ((*it)->getIdx() == idx)
return *it;
}
@@ -82,8 +78,8 @@ IReplicatedInterfaceItem* ReplicatedInterfaceItemBase::getSystemPort() const {
return dynamic_cast<IInterfaceItemOwner*>(getParent())->getSystemPort();
}
-std::string ReplicatedInterfaceItemBase::toString() const {
- return "replicated port " + getName();
+String ReplicatedInterfaceItemBase::toString() const {
+ return String("replicated port ") + getName();
}
IInterfaceItem* ReplicatedInterfaceItemBase::connectWith(IInterfaceItem* peer) {
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedInterfaceItemBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedInterfaceItemBase.h
index 4738382da..bf1447154 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedInterfaceItemBase.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedInterfaceItemBase.h
@@ -15,9 +15,8 @@
#include "common/modelbase/IInterfaceItemOwner.h"
#include "common/modelbase/InterfaceItemBase.h"
#include "common/modelbase/IReplicatedInterfaceItem.h"
-#include <queue>
-#include <string>
-#include <vector>
+#include "common/containers/String.h"
+#include "common/containers/Vector.h"
namespace etRuntime {
@@ -45,23 +44,23 @@ public:
virtual IEventReceiver* getEventReceiver() const;
virtual IReplicatedInterfaceItem* getSystemPort() const;
- std::string toString() const;
+ String toString() const;
virtual IInterfaceItem* connectWith(IInterfaceItem* peer);
protected:
- ReplicatedInterfaceItemBase(IInterfaceItemOwner* owner, const std::string& name, int localId);
+ ReplicatedInterfaceItemBase(IInterfaceItemOwner* owner, const String& name, int localId);
- std::vector<InterfaceItemBase*>& getItems() {
+ Vector<InterfaceItemBase*>& getItems() {
return m_items;
}
- virtual InterfaceItemBase* createInterfaceItem(IInterfaceItemOwner* rcv, const std::string& name, int lid, int idx) = 0;
+ virtual InterfaceItemBase* createInterfaceItem(IInterfaceItemOwner* rcv, const String& name, int lid, int idx) = 0;
private:
int m_localId;
- std::vector<InterfaceItemBase*> m_items;
- std::queue<int> m_releasedIndices;
+ Vector<InterfaceItemBase*> m_items;
+ Vector<int> m_releasedIndices;
int getFreeIndex();
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedPortBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedPortBase.h
index a3975093a..b4afdd76e 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedPortBase.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedPortBase.h
@@ -13,7 +13,6 @@
#define SRC_COMMON_MODELBASE_REPLICATEDPORTBASE_H_
#include "common/modelbase/ReplicatedInterfaceItemBase.h"
-#include <string>
namespace etRuntime {
@@ -22,7 +21,7 @@ public:
virtual ~ReplicatedPortBase() {}
protected:
- ReplicatedPortBase(IInterfaceItemOwner* owner, const std::string& name, int localId) :
+ ReplicatedPortBase(IInterfaceItemOwner* owner, const String& name, int localId) :
ReplicatedInterfaceItemBase(owner, name, localId) {
}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.cpp
index d7e33a04a..762ca2910 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.cpp
@@ -16,22 +16,20 @@
#include "common/messaging/MessageServiceController.h"
#include "common/messaging/RTServices.h"
#include "common/modelbase/ActorClassBase.h"
-#include <iostream>
-#include <iterator>
-#include <map>
-#include <string>
-#include <vector>
-
namespace etRuntime {
-SubSystemClassBase::SubSystemClassBase(IRTObject* parent, std::string name) :
+SubSystemClassBase::SubSystemClassBase(IRTObject* parent, String name) :
RTObject(parent, name),
m_RTSystemPort(this, IFITEM_RTSystemPort) {
- DebuggingService::getInstance().getAsyncLogger().setMSC(name + "_Async", "log/");
+ String asyncMSCname(name);
+ asyncMSCname += "_Async";
+ String syncMSCname(name);
+ syncMSCname += "_Sync";
+ DebuggingService::getInstance().getAsyncLogger().setMSC(asyncMSCname.c_str(), "log/");
DebuggingService::getInstance().getAsyncLogger().open();
- DebuggingService::getInstance().getSyncLogger().setMSC(name + "_Sync", "log/");
+ DebuggingService::getInstance().getSyncLogger().setMSC(syncMSCname.c_str(), "log/");
DebuggingService::getInstance().getSyncLogger().open();
DebuggingService::getInstance().getSyncLogger().setObjectName("main");
@@ -40,7 +38,7 @@ SubSystemClassBase::SubSystemClassBase(IRTObject* parent, std::string name) :
void SubSystemClassBase::init() {
- std::cout << "*** MainComponent " << getInstancePath() << "::init ***" << std::endl;
+ printf("*** MainComponent %s::init ***\n", getInstancePath().c_str());
// MessageService
instantiateMessageServices();
@@ -55,7 +53,7 @@ void SubSystemClassBase::init() {
// std::cout << toStringRecursive() << std::endl;
// initialize all actor instances
- for (std::vector<IRTObject*>::iterator it = getChildren().begin(); it != getChildren().end(); ++it) {
+ for (ChildList::iterator it = getChildren().begin(); it != getChildren().end(); ++it) {
ActorClassBase* child = dynamic_cast<ActorClassBase*>(*it);
if (child != 0)
child->init();
@@ -72,50 +70,50 @@ void SubSystemClassBase::start() {
}
void SubSystemClassBase::stop() {
- std::cout << "*** MainComponent " << getInstancePath() << "::stop ***" << std::endl;
+ printf("*** MainComponent %s::stop ***\n", getInstancePath().c_str());
RTServices::getInstance().getMsgSvcCtrl().stop();
- std::cout << "=== done stop MsgSvcCtrl" << std::endl;
+ printf("=== done stop MsgSvcCtrl\n");
// stop all actor instances
- for (std::vector<IRTObject*>::iterator it = getChildren().begin(); it != getChildren().end(); ++it) {
+ for (ChildList::iterator it = getChildren().begin(); it != getChildren().end(); ++it) {
ActorClassBase* child = dynamic_cast<ActorClassBase*>(*it);
if (child != 0)
child->stop();
}
- std::cout << "=== done stop actor instances" << std::endl;
+ printf("=== done stop actor instances\n");
}
void SubSystemClassBase::destroy() {
- std::cout << "*** MainComponent " << this->getInstancePath() << "::destroy ***" << std::endl;
+ printf("*** MainComponent %s::destroy ***\n", this->getInstancePath().c_str());
RTObject::destroy();
// std::cout << toStringRecursive() << std::endl;
- std::cout << "=== done destroy actor instances" << std::endl;
+ printf("=== done destroy actor instances\n");
DebuggingService::getInstance().getAsyncLogger().close();
DebuggingService::getInstance().getSyncLogger().close();
- std::cout << "=== done close loggers" << std::endl;
+ printf("=== done close loggers\n");
RTServices::getInstance().destroy();
- std::cout << "=== done destroy RTServices\n\n\n" << std::endl;
+ printf("=== done destroy RTServices\n\n\n\n");
}
IMessageService* SubSystemClassBase::getMsgService(int idx) const {
return RTServices::getInstance().getMsgSvcCtrl().getMsgSvc(idx);
}
-ActorClassBase* SubSystemClassBase::getInstance(const std::string& path) const {
+ActorClassBase* SubSystemClassBase::getInstance(const String& path) const {
IRTObject* object = getObject(path);
return dynamic_cast<ActorClassBase*>(object);
}
-void SubSystemClassBase::addPathToThread(const std::string& path, int thread) {
+void SubSystemClassBase::addPathToThread(const String& path, int thread) {
m_path2thread[path] = thread;
}
-int SubSystemClassBase::getThreadForPath(const std::string& path) const {
- std::map<std::string, int> ::const_iterator it = m_path2thread.find(path);
+int SubSystemClassBase::getThreadForPath(const String& path) const {
+ Map<String, int> ::const_iterator it = m_path2thread.find(path);
if (it == m_path2thread.end())
return -1;
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.h
index 11bd28c61..f0172333f 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.h
@@ -13,13 +13,12 @@
#ifndef SUBSYSTEMCLASSBASE_H_
#define SUBSYSTEMCLASSBASE_H_
+#include "common/containers/Map.h"
#include "common/modelbase/IEventReceiver.h"
#include "common/modelbase/IInterfaceItemOwner.h"
#include "common/modelbase/IReplicatedInterfaceItem.h"
#include "common/modelbase/RTSystemProtocol.h"
#include "etDatatypes.h"
-#include <map>
-#include <string>
namespace etRuntime {
@@ -43,10 +42,10 @@ public:
IMessageService* getMsgService(int idx) const;
Address getFreeAddress(int msgSvcId) const;
- ActorClassBase* getInstance(const std::string& path) const;
+ ActorClassBase* getInstance(const String& path) const;
- void addPathToThread(const std::string& path, int thread);
- int getThreadForPath(const std::string& path) const;
+ void addPathToThread(const String& path, int thread);
+ int getThreadForPath(const String& path) const;
void resetAll();
@@ -68,7 +67,7 @@ public:
protected:
- SubSystemClassBase(IRTObject* parent, std::string name);
+ SubSystemClassBase(IRTObject* parent, String name);
//--------------------- ports
RTSystemConjPort m_RTSystemPort;
@@ -78,7 +77,7 @@ protected:
private:
- std::map<std::string, int> m_path2thread;
+ Map<String, int> m_path2thread;
SubSystemClassBase();
SubSystemClassBase(SubSystemClassBase const&);
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.cpp
index 931527644..09c8102d0 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.cpp
@@ -15,26 +15,24 @@
#include "common/modelbase/SubSystemClassBase.h"
#include "runtime/etRuntime.h"
#include "etUnit/etUnit.h"
-#include <iostream>
-#include <sstream>
#include <cstring>
namespace etRuntime {
-const std::string SubSystemRunnerBase::OPTION_RUN_AS_TEST = "-run_as_test";
-const std::string SubSystemRunnerBase::OPTION_RUN_HEADLESS = "-headless";
+const String SubSystemRunnerBase::OPTION_RUN_AS_TEST = "-run_as_test";
+const String SubSystemRunnerBase::OPTION_RUN_HEADLESS = "-headless";
void SubSystemRunnerBase::run(SubSystemClassBase& main_component, int argc, char* argv[]) {
- std::cout << "*** T H E B E G I N ***" << std::endl;
+ printf("*** T H E B E G I N ***\n");
etBool headless = false;
for (int i = 1; i < argc; ++i) { // omit first argument, which is the program name
if (OPTION_RUN_AS_TEST.compare(argv[i]) == 0) {
- std::cout << "*** running as test" << std::endl;
+ printf("*** running as test\n");
headless = true;
} else if (OPTION_RUN_HEADLESS.compare(argv[i]) == 0) {
- std::cout << "*** running headless" << std::endl;
+ printf("*** running headless\n");
headless = true;
}
}
@@ -52,7 +50,7 @@ void SubSystemRunnerBase::run(SubSystemClassBase& main_component, int argc, char
main_component.stop(); // lifecycle stop
main_component.destroy(); // lifecycle destroy
- std::cout << "*** T H E E N D ***" << std::endl;
+ printf("*** T H E E N D ***\n");
}
@@ -83,9 +81,9 @@ void SubSystemRunnerBase::waitForQuit() {
}
void SubSystemRunnerBase::waitForTerminate() {
- std::cout << "=== waitForTestcase: before acq. semaphore" << std::endl;
+ printf("=== waitForTestcase: before acq. semaphore\n");
etSema_waitForWakeup(etRuntime_getTerminateSemaphore());
- std::cout << "=== waitForTestcase: after acq. semaphore" << std::endl;
+ printf("=== waitForTestcase: after acq. semaphore\n");
}
} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.h
index 156f1d096..89e44f535 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.h
@@ -13,7 +13,7 @@
#ifndef SUBSYSTEMRUNNERBASE_H_
#define SUBSYSTEMRUNNERBASE_H_
-#include <string>
+#include "common/containers/String.h"
namespace etRuntime {
@@ -33,8 +33,8 @@ protected:
static void waitForQuit();
private:
- static const std::string OPTION_RUN_AS_TEST;
- static const std::string OPTION_RUN_HEADLESS;
+ static const String OPTION_RUN_AS_TEST;
+ static const String OPTION_RUN_HEADLESS;
SubSystemRunnerBase(SubSystemRunnerBase const&);
SubSystemRunnerBase& operator=(SubSystemRunnerBase const&);
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SystemPortOwner.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SystemPortOwner.h
index 4cd43f9a6..8b74e9d20 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SystemPortOwner.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SystemPortOwner.h
@@ -15,7 +15,6 @@
#include "common/messaging/RTObject.h"
#include "common/modelbase/EventReceiver.h"
#include "common/modelbase/IInterfaceItemOwner.h"
-#include <string>
namespace etRuntime {
@@ -39,7 +38,7 @@ public:
}
protected:
- SystemPortOwner(IRTObject* parent, const std::string& name) :
+ SystemPortOwner(IRTObject* parent, const String& name) :
EventReceiver(parent, name) {
}

Back to the top