Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2017-01-04 15:07:12 -0500
committerHenrik Rentz-Reichert2017-01-09 11:41:16 -0500
commit9b02d5a62ea41136b46b744f7b2c1cf50f30a888 (patch)
treed7473847da1a9e3a470195f384f62322b48057db
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
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend9
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/NodeGen.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/NodeRunnerGen.xtend12
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend44
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend8
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.java10
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/NodeGen.java4
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/NodeRunnerGen.java31
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java55
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.java8
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.c.zipbin104127 -> 104131 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.java.zipbin210031 -> 210088 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zipbin169532 -> 194420 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.cpp.zipbin15875 -> 15875 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zipbin26328 -> 47905 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zipbin200154 -> 200344 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.cpp.zipbin69643 -> 87358 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zipbin70256 -> 70307 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.c.zipbin12269 -> 12275 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.cpp.zipbin14000 -> 14006 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.c.zipbin20896 -> 20906 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.cpp.zipbin22163 -> 22173 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zipbin17873 -> 17881 bytes
-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
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/RunAllTestCases.cpp32
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/MapTest.cpp53
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/MapTest.h36
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/PairTest.cpp61
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/PairTest.h35
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/SetTest.cpp106
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/SetTest.h36
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/StringTest.cpp121
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/StringTest.h35
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/VectorTest.cpp86
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/VectorTest.h36
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/debugging/DebuggingServiceTest.cpp50
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/debugging/DebuggingServiceTest.h6
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/debugging/MSCLoggerTest.cpp45
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageDispatcherTest.cpp16
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageDispatcherTest.h4
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageServiceTest.h2
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/RTObjectTest.cpp18
102 files changed, 2676 insertions, 541 deletions
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend
index cf705d93d..a9366db52 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend
@@ -78,7 +78,6 @@ class ActorClassGen extends GenericActorClassGenerator {
#include "common/messaging/Address.h"
#include "common/messaging/IMessageReceiver.h"
#include "common/debugging/DebuggingService.h"
- #include <vector>
«FOR pc : root.getReferencedProtocolClasses(ac)»
#include "«pc.path»«pc.name».h"
@@ -140,7 +139,7 @@ class ActorClassGen extends GenericActorClassGenerator {
public:
//--------------------- construction
- «ac.name»(etRuntime::IRTObject* parent, const std::string& name);
+ «ac.name»(etRuntime::IRTObject* parent, const String& name);
void initialize(void);
«IF Main::settings.generateMSCInstrumentation»
void setProbesActive(bool recursive, bool active);
@@ -181,11 +180,11 @@ class ActorClassGen extends GenericActorClassGenerator {
class Replicated«clsname» : public ReplicatedActorClassBase {
public:
- Replicated«clsname»(IRTObject* parent, const std::string& name) :
+ Replicated«clsname»(IRTObject* parent, const String& name) :
ReplicatedActorClassBase(parent, name) {}
protected:
- ActorClassBase* createActor(IRTObject* parent, const std::string& name) {
+ ActorClassBase* createActor(IRTObject* parent, const String& name) {
return new «clsname»(parent, name);
}
};
@@ -244,7 +243,7 @@ class ActorClassGen extends GenericActorClassGenerator {
«ac.userCode3.userCode»
- «clsname»::«clsname»(etRuntime::IRTObject* parent, const std::string& name)
+ «clsname»::«clsname»(etRuntime::IRTObject* parent, const String& name)
«ac.generateConstructorInitalizerList»
{
«IF Main::settings.generateMSCInstrumentation»
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/NodeGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/NodeGen.xtend
index 48a98f833..bf05af6c7 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/NodeGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/NodeGen.xtend
@@ -114,7 +114,7 @@ class NodeGen {
«ENDIF»
«ENDFOR»
- «clsname»(IRTObject* parent, const std::string& name);
+ «clsname»(IRTObject* parent, const String& name);
~«clsname»();
virtual void receiveEvent(etRuntime::InterfaceItemBase* ifitem, int evt, void* data);
@@ -199,7 +199,7 @@ class NodeGen {
const int «clsname»::«thread.value.threadId» = «thread.index0»;
«ENDFOR»
- «clsname»::«clsname»(IRTObject* parent, const std::string& name)
+ «clsname»::«clsname»(IRTObject* parent, const String& name)
«cc.generateConstructorInitalizerList»
«FOR thread : threads»
, msgSvc_«thread.name»(NULL)
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/NodeRunnerGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/NodeRunnerGen.xtend
index 5c205ff64..181a815be 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/NodeRunnerGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/NodeRunnerGen.xtend
@@ -90,6 +90,10 @@ class NodeRunnerGen {
#include "«clsname».h"
#include "common/modelbase/RTSystem.h"
+ #include "common/containers/String.h"
+ #include "common/containers/Vector.h"
+ #include "common/containers/Set.h"
+ #include "common/containers/Map.h"
using namespace etRuntime;
@@ -108,6 +112,14 @@ class NodeRunnerGen {
««« // TODO JH crash
//delete sys;
+
+ printf("String allocations %d and deallocations %d\n", etRuntime::String::getNAllocations(), etRuntime::String::getNDeallocations());
+ printf("String creations %d and destructions %d\n", etRuntime::String::getNCreated(), etRuntime::String::getNDestroyed());
+ printf("Vector allocations %d and deallocations %d\n", etRuntime::VectorStats::getNAllocations(), etRuntime::VectorStats::getNDeallocations());
+ printf("Vector creations %d and destructions %d\n", etRuntime::VectorStats::getNCreated(), etRuntime::VectorStats::getNDestroyed());
+ printf("Set creations %d and destructions %d\n", etRuntime::SetStats::getNCreated(), etRuntime::SetStats::getNDestroyed());
+ printf("Map creations %d and destructions %d\n", etRuntime::MapStats::getNCreated(), etRuntime::MapStats::getNDestroyed());
+ fflush(stdout);
return 0;
}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
index ead55a961..223cf131d 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
@@ -106,10 +106,10 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
static bool isValidIncomingEvtID(int evtId) {
return ((«IF pc.incomingMessages.size == 0»MSG_MAX«ELSE»IN_«pc.incomingMessages.get(0).name»«ENDIF» <= 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[];
};
@@ -135,8 +135,8 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«pclass.userCode.userCode»
«ENDIF»
public:
- «portClassName»(etRuntime::IInterfaceItemOwner* actor, const std::string& name, int localId);
- «portClassName»(etRuntime::IInterfaceItemOwner* actor, const std::string& name, int localId, int idx);
+ «portClassName»(etRuntime::IInterfaceItemOwner* actor, const etRuntime::String& name, int localId);
+ «portClassName»(etRuntime::IInterfaceItemOwner* actor, const etRuntime::String& name, int localId, int idx);
«IF Main::settings.generateMSCInstrumentation»
virtual void destroy();
@@ -162,7 +162,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
class «replPortClassName» : public etRuntime::ReplicatedPortBase {
public:
- «replPortClassName»(etRuntime::IInterfaceItemOwner* actor, const std::string& name, int localId);
+ «replPortClassName»(etRuntime::IInterfaceItemOwner* actor, const etRuntime::String& name, int localId);
int getReplication() const { return getNInterfaceItems(); }
int getIndexOf(const etRuntime::InterfaceItemBase& ifitem) const { return ifitem.getIdx(); }
@@ -181,7 +181,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«ENDIF»
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 «portClassName»(rcv, name, lid, idx);
}
@@ -205,8 +205,6 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
#include "common/messaging/Address.h"
#include "common/messaging/Message.h"
#include "common/modelbase/IEventReceiver.h"
- #include <iterator>
- #include <vector>
using namespace etRuntime;
@@ -215,14 +213,14 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«pc.userCode(3)»
/* message names as strings for debugging (generate MSC) */
- const std::string «pc.name»::s_messageStrings[] = {"MIN", «FOR m : pc.getAllOutgoingMessages()»"«m.name»",«ENDFOR» «FOR m : pc.getAllIncomingMessages()»"«m.name»",«ENDFOR»"MAX"};
+ const String «pc.name»::s_messageStrings[] = {"MIN", «FOR m : pc.getAllOutgoingMessages()»"«m.name»",«ENDFOR» «FOR m : pc.getAllIncomingMessages()»"«m.name»",«ENDFOR»"MAX"};
- const std::string& «pc.name»::getMessageString(int msg_id) {
+ const String& «pc.name»::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;
}
}
@@ -245,12 +243,12 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
// «IF conj»conjugated «ENDIF»port class
//------------------------------------------------------------------------------------------------------------
- «portClassName»::«portClassName»(IInterfaceItemOwner* actor, const std::string& name, int localId)
+ «portClassName»::«portClassName»(IInterfaceItemOwner* actor, const String& name, int localId)
«pclass.generateConstructorInitalizerList('0')»
{
}
- «portClassName»::«portClassName»(IInterfaceItemOwner* actor, const std::string& name, int localId, int idx)
+ «portClassName»::«portClassName»(IInterfaceItemOwner* actor, const String& name, int localId, int idx)
«pclass.generateConstructorInitalizerList('idx')»
{
«IF pclass != null»«initHelper.genExtraInitializers(pclass.attributes)»«ENDIF»
@@ -266,11 +264,11 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
void «portClassName»::receive(const Message* msg) {
// TODO JH further
if (! «pc.name»::«IF conj»isValidOutgoingEvtID«ELSE»isValidIncomingEvtID«ENDIF»(msg->getEvtId())) {
- std::cout << "unknown" << std::endl;
+ //std::cout << "unknown" << std::endl;
}
«IF Main::settings.generateMSCInstrumentation»
- DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), «pc.name»::getMessageString(msg->getEvtId()));
+ DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), «pc.name»::getMessageString(msg->getEvtId()).c_str());
«ENDIF»
«IF pc.handlesReceive(conj)»
@@ -305,7 +303,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
//------------------------------------------------------------------------------------------------------------
// «IF conj»conjugated «ENDIF»replicated port class
//------------------------------------------------------------------------------------------------------------
- «replPortClassName»::«replPortClassName»(IInterfaceItemOwner* actor, const std::string& name, int localId) :
+ «replPortClassName»::«replPortClassName»(IInterfaceItemOwner* actor, const String& name, int localId) :
ReplicatedPortBase(actor, name, localId)
{
}
@@ -314,7 +312,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
// incoming messages
«FOR m : pc.getAllIncomingMessages()»
«messageSignatureDefinition(m, replPortClassName, false)»{
- 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<«portClassName»*>(*it))->«messageCall(m, false)»;
}
}
@@ -323,7 +321,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
// outgoing messages
«FOR m : pc.getAllOutgoingMessages()»
«messageSignatureDefinition(m, replPortClassName, false)»{
- 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<«portClassName»*>(*it))->«messageCall(m, false)»;
}
}
@@ -375,7 +373,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«messageSignatureDefinition(m, classPrefix, true)» {
«IF Main::settings.generateMSCInstrumentation»
DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
- «portClassName»::getMessageString(«portClassName»::«dir»_«m.name»));
+ «portClassName»::getMessageString(«portClassName»::«dir»_«m.name»).c_str());
«ENDIF»
if (getPeerAddress().isValid()) {
««« we have to use a dynamic cast here because we have a virtual base class
@@ -422,7 +420,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
class «pc.getPortClassName(true)» : public etRuntime::DataSendPort {
public:
- «pc.getPortClassName(true)»(etRuntime::IRTObject* parent, const std::string& name, int localId);
+ «pc.getPortClassName(true)»(etRuntime::IRTObject* parent, const etRuntime::String& name, int localId);
// getters and setters
«FOR msg : sentMsgs»
@@ -444,7 +442,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
class «pc.getPortClassName(false)» : public etRuntime::DataReceivePort {
public:
- «pc.getPortClassName(false)»(etRuntime::IRTObject* parent, const std::string& name, int localId);
+ «pc.getPortClassName(false)»(etRuntime::IRTObject* parent, const etRuntime::String& name, int localId);
// getters
«FOR msg : sentMsgs»
@@ -489,7 +487,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
// send port holds data
// constructor
- «pc.getPortClassName(true)»::«pc.getPortClassName(true)»(IRTObject* parent, const std::string& name, int localId) :
+ «pc.getPortClassName(true)»::«pc.getPortClassName(true)»(IRTObject* parent, const String& name, int localId) :
DataSendPort(parent, name, localId)
{
}
@@ -497,7 +495,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
// receive port accesses send port
// constructor
- «pc.getPortClassName(false)»::«pc.getPortClassName(false)»(IRTObject* parent, const std::string& name, int localId) :
+ «pc.getPortClassName(false)»::«pc.getPortClassName(false)»(IRTObject* parent, const String& name, int localId) :
DataReceivePort(parent, name, localId),
m_peer(0)
{
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend
index 3e1c142ac..514cd75db 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend
@@ -40,7 +40,7 @@ class StateMachineGen extends GenericStateMachineGenerator {
'''
«IF Main::settings.generateMSCInstrumentation || Main::settings.generateWithVerboseOutput»
// state names
- const std::string «clsName»::s_stateStrings[] = {
+ const String «clsName»::s_stateStrings[] = {
"<no state>",
"<top>",
«FOR state : states SEPARATOR ","»
@@ -52,11 +52,11 @@ class StateMachineGen extends GenericStateMachineGenerator {
void «clsName»::setState(int new_state) {
«IF Main::settings.generateMSCInstrumentation»
- DebuggingService::getInstance().addActorState(*this, s_stateStrings[new_state]);
+ DebuggingService::getInstance().addActorState(*this, s_stateStrings[new_state].c_str());
«ENDIF»
«IF Main::settings.generateWithVerboseOutput»
if (s_stateStrings[new_state] != "Idle") {
- std::cout << getInstancePath() << " -> " << s_stateStrings[new_state] << std::endl;
+ std::cout << getInstancePath().c_str() << " -> " << s_stateStrings[new_state].c_str() << std::endl;
}
«ENDIF»
m_state = new_state;
@@ -65,7 +65,7 @@ class StateMachineGen extends GenericStateMachineGenerator {
else
'''
«IF Main::settings.generateMSCInstrumentation || Main::settings.generateWithVerboseOutput»
- static const std::string s_stateStrings[];
+ static const String s_stateStrings[];
«ENDIF»
static const int s_numberOfStates;
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.java
index 9505a4fc0..270831896 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.java
@@ -207,8 +207,6 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.newLine();
_builder.append("#include \"common/debugging/DebuggingService.h\"");
_builder.newLine();
- _builder.append("#include <vector>");
- _builder.newLine();
_builder.newLine();
{
EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
@@ -405,7 +403,7 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append("\t\t");
String _name_11 = ac.getName();
_builder.append(_name_11, "\t\t");
- _builder.append("(etRuntime::IRTObject* parent, const std::string& name);");
+ _builder.append("(etRuntime::IRTObject* parent, const String& name);");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("void initialize(void);");
@@ -542,7 +540,7 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append("\t");
_builder.append("Replicated");
_builder.append(clsname, "\t");
- _builder.append("(IRTObject* parent, const std::string& name) :");
+ _builder.append("(IRTObject* parent, const String& name) :");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("ReplicatedActorClassBase(parent, name) {}");
@@ -552,7 +550,7 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append("protected:");
_builder.newLine();
_builder.append("\t");
- _builder.append("ActorClassBase* createActor(IRTObject* parent, const std::string& name) {");
+ _builder.append("ActorClassBase* createActor(IRTObject* parent, const String& name) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("return new ");
@@ -770,7 +768,7 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append(clsname, "");
_builder.append("::");
_builder.append(clsname, "");
- _builder.append("(etRuntime::IRTObject* parent, const std::string& name)");
+ _builder.append("(etRuntime::IRTObject* parent, const String& name)");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
CharSequence _generateConstructorInitalizerList = this.generateConstructorInitalizerList(ac);
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/NodeGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/NodeGen.java
index 8b127a7db..74632625e 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/NodeGen.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/NodeGen.java
@@ -255,7 +255,7 @@ public class NodeGen {
_builder.newLine();
_builder.append("\t\t");
_builder.append(clsname, "\t\t");
- _builder.append("(IRTObject* parent, const std::string& name);");
+ _builder.append("(IRTObject* parent, const String& name);");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("~");
@@ -472,7 +472,7 @@ public class NodeGen {
_builder.append(clsname, "");
_builder.append("::");
_builder.append(clsname, "");
- _builder.append("(IRTObject* parent, const std::string& name)");
+ _builder.append("(IRTObject* parent, const String& name)");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
CharSequence _generateConstructorInitalizerList = this.generateConstructorInitalizerList(cc);
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/NodeRunnerGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/NodeRunnerGen.java
index 8a3c52ab3..715a31c75 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/NodeRunnerGen.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/NodeRunnerGen.java
@@ -186,6 +186,14 @@ public class NodeRunnerGen {
_builder.newLineIfNotEmpty();
_builder.append("#include \"common/modelbase/RTSystem.h\"");
_builder.newLine();
+ _builder.append("#include \"common/containers/String.h\"");
+ _builder.newLine();
+ _builder.append("#include \"common/containers/Vector.h\"");
+ _builder.newLine();
+ _builder.append("#include \"common/containers/Set.h\"");
+ _builder.newLine();
+ _builder.append("#include \"common/containers/Map.h\"");
+ _builder.newLine();
_builder.newLine();
_builder.append("using namespace etRuntime;");
_builder.newLine();
@@ -252,6 +260,29 @@ public class NodeRunnerGen {
_builder.append("\t");
_builder.append("//delete sys;");
_builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("printf(\"String allocations %d and deallocations %d\\n\", etRuntime::String::getNAllocations(), etRuntime::String::getNDeallocations());");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("printf(\"String creations %d and destructions %d\\n\", etRuntime::String::getNCreated(), etRuntime::String::getNDestroyed());");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("printf(\"Vector allocations %d and deallocations %d\\n\", etRuntime::VectorStats::getNAllocations(), etRuntime::VectorStats::getNDeallocations());");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("printf(\"Vector creations %d and destructions %d\\n\", etRuntime::VectorStats::getNCreated(), etRuntime::VectorStats::getNDestroyed());");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("printf(\"Set creations %d and destructions %d\\n\", etRuntime::SetStats::getNCreated(), etRuntime::SetStats::getNDestroyed());");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("printf(\"Map creations %d and destructions %d\\n\", etRuntime::MapStats::getNCreated(), etRuntime::MapStats::getNDestroyed());");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("fflush(stdout);");
+ _builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("return 0;");
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java
index 3da64299f..a1a46c78d 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java
@@ -269,14 +269,14 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("}");
_builder.newLine();
_builder.append("\t\t");
- _builder.append("static const std::string& getMessageString(int msg_id);");
+ _builder.append("static const etRuntime::String& getMessageString(int msg_id);");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("private:");
_builder.newLine();
_builder.append("\t\t");
- _builder.append("static const std::string s_messageStrings[];");
+ _builder.append("static const etRuntime::String s_messageStrings[];");
_builder.newLine();
_builder.newLine();
_builder.append("};");
@@ -337,11 +337,11 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.newLine();
_builder.append("\t ");
_builder.append(portClassName, "\t ");
- _builder.append("(etRuntime::IInterfaceItemOwner* actor, const std::string& name, int localId);");
+ _builder.append("(etRuntime::IInterfaceItemOwner* actor, const etRuntime::String& name, int localId);");
_builder.newLineIfNotEmpty();
_builder.append("\t ");
_builder.append(portClassName, "\t ");
- _builder.append("(etRuntime::IInterfaceItemOwner* actor, const std::string& name, int localId, int idx);");
+ _builder.append("(etRuntime::IInterfaceItemOwner* actor, const etRuntime::String& name, int localId, int idx);");
_builder.newLineIfNotEmpty();
_builder.newLine();
{
@@ -417,7 +417,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.newLine();
_builder.append("\t\t");
_builder.append(replPortClassName, "\t\t");
- _builder.append("(etRuntime::IInterfaceItemOwner* actor, const std::string& name, int localId);");
+ _builder.append("(etRuntime::IInterfaceItemOwner* actor, const etRuntime::String& name, int localId);");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t\t");
@@ -469,7 +469,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("protected:");
_builder.newLine();
_builder.append("\t\t");
- _builder.append("virtual etRuntime::InterfaceItemBase* createInterfaceItem(etRuntime::IInterfaceItemOwner* rcv, const std::string& name, int lid, int idx) {");
+ _builder.append("virtual etRuntime::InterfaceItemBase* createInterfaceItem(etRuntime::IInterfaceItemOwner* rcv, const etRuntime::String& name, int lid, int idx) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("return new ");
@@ -527,10 +527,6 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.newLine();
_builder.append("#include \"common/modelbase/IEventReceiver.h\"");
_builder.newLine();
- _builder.append("#include <iterator>");
- _builder.newLine();
- _builder.append("#include <vector>");
- _builder.newLine();
_builder.newLine();
_builder.append("using namespace etRuntime;");
_builder.newLine();
@@ -545,7 +541,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.newLine();
_builder.append("/* message names as strings for debugging (generate MSC) */");
_builder.newLine();
- _builder.append("const std::string ");
+ _builder.append("const String ");
String _name_1 = pc.getName();
_builder.append(_name_1, "");
_builder.append("::s_messageStrings[] = {\"MIN\", ");
@@ -571,7 +567,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("\"MAX\"};");
_builder.newLineIfNotEmpty();
_builder.newLine();
- _builder.append("const std::string& ");
+ _builder.append("const String& ");
String _name_4 = pc.getName();
_builder.append(_name_4, "");
_builder.append("::getMessageString(int msg_id) {");
@@ -589,7 +585,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("// id out of range");
_builder.newLine();
_builder.append("\t\t");
- _builder.append("static const std::string errorMsg = \"Message ID out of range\";");
+ _builder.append("static const String errorMsg = \"Message ID out of range\";");
_builder.newLine();
_builder.append("\t\t");
_builder.append("return errorMsg;");
@@ -637,7 +633,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append(portClassName, "");
_builder.append("::");
_builder.append(portClassName, "");
- _builder.append("(IInterfaceItemOwner* actor, const std::string& name, int localId)");
+ _builder.append("(IInterfaceItemOwner* actor, const String& name, int localId)");
_builder.newLineIfNotEmpty();
_builder.append("\t");
CharSequence _generateConstructorInitalizerList = this.generateConstructorInitalizerList(pclass, "0");
@@ -651,7 +647,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append(portClassName, "");
_builder.append("::");
_builder.append(portClassName, "");
- _builder.append("(IInterfaceItemOwner* actor, const std::string& name, int localId, int idx)");
+ _builder.append("(IInterfaceItemOwner* actor, const String& name, int localId, int idx)");
_builder.newLineIfNotEmpty();
_builder.append("\t");
CharSequence _generateConstructorInitalizerList_1 = this.generateConstructorInitalizerList(pclass, "idx");
@@ -713,7 +709,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("(msg->getEvtId())) {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
- _builder.append("std::cout << \"unknown\" << std::endl;");
+ _builder.append("//std::cout << \"unknown\" << std::endl;");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
@@ -727,7 +723,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), ");
String _name_1 = pc.getName();
_builder.append(_name_1, "\t");
- _builder.append("::getMessageString(msg->getEvtId()));");
+ _builder.append("::getMessageString(msg->getEvtId()).c_str());");
_builder.newLineIfNotEmpty();
}
}
@@ -841,7 +837,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append(replPortClassName, "");
_builder.append("::");
_builder.append(replPortClassName, "");
- _builder.append("(IInterfaceItemOwner* actor, const std::string& name, int localId) :");
+ _builder.append("(IInterfaceItemOwner* actor, const String& name, int localId) :");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("ReplicatedPortBase(actor, name, localId)");
@@ -863,7 +859,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("{");
_builder.newLineIfNotEmpty();
_builder.append("\t");
- _builder.append("for (std::vector<etRuntime::InterfaceItemBase*>::iterator it = getItems().begin(); it != getItems().end(); ++it) {");
+ _builder.append("for (Vector<etRuntime::InterfaceItemBase*>::iterator it = getItems().begin(); it != getItems().end(); ++it) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("(dynamic_cast<");
@@ -891,7 +887,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("{");
_builder.newLineIfNotEmpty();
_builder.append("\t");
- _builder.append("for (std::vector<etRuntime::InterfaceItemBase*>::iterator it = getItems().begin(); it != getItems().end(); ++it) {");
+ _builder.append("for (Vector<etRuntime::InterfaceItemBase*>::iterator it = getItems().begin(); it != getItems().end(); ++it) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("(dynamic_cast<");
@@ -1141,15 +1137,16 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder_4.append("DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),");
_builder_4.newLine();
_builder_4.append("\t");
- _builder_4.append(portClassName, "\t");
+ _builder_4.append("\t");
+ _builder_4.append(portClassName, "\t\t");
_builder_4.append("::getMessageString(");
- _builder_4.append(portClassName, "\t");
+ _builder_4.append(portClassName, "\t\t");
_builder_4.append("::");
- _builder_4.append(dir, "\t");
+ _builder_4.append(dir, "\t\t");
_builder_4.append("_");
String _name_2 = m.getName();
- _builder_4.append(_name_2, "\t");
- _builder_4.append("));");
+ _builder_4.append(_name_2, "\t\t");
+ _builder_4.append(").c_str());");
_builder_4.newLineIfNotEmpty();
}
}
@@ -1273,7 +1270,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("\t");
String _portClassName_1 = this.roomExt.getPortClassName(pc, true);
_builder.append(_portClassName_1, "\t");
- _builder.append("(etRuntime::IRTObject* parent, const std::string& name, int localId);");
+ _builder.append("(etRuntime::IRTObject* parent, const etRuntime::String& name, int localId);");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
@@ -1366,7 +1363,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("\t");
String _portClassName_3 = this.roomExt.getPortClassName(pc, false);
_builder.append(_portClassName_3, "\t");
- _builder.append("(etRuntime::IRTObject* parent, const std::string& name, int localId);");
+ _builder.append("(etRuntime::IRTObject* parent, const etRuntime::String& name, int localId);");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
@@ -1478,7 +1475,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("::");
String _portClassName_1 = this.roomExt.getPortClassName(pc, true);
_builder.append(_portClassName_1, "");
- _builder.append("(IRTObject* parent, const std::string& name, int localId) :");
+ _builder.append("(IRTObject* parent, const String& name, int localId) :");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("DataSendPort(parent, name, localId)");
@@ -1498,7 +1495,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("::");
String _portClassName_3 = this.roomExt.getPortClassName(pc, false);
_builder.append(_portClassName_3, "");
- _builder.append("(IRTObject* parent, const std::string& name, int localId) :");
+ _builder.append("(IRTObject* parent, const String& name, int localId) :");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("DataReceivePort(parent, name, localId),");
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.java
index 589160981..579716fe0 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.java
@@ -58,7 +58,7 @@ public class StateMachineGen extends GenericStateMachineGenerator {
if ((Main.getSettings().isGenerateMSCInstrumentation() || Main.getSettings().isGenerateWithVerboseOutput())) {
_builder.append("// state names");
_builder.newLine();
- _builder.append("const std::string ");
+ _builder.append("const String ");
_builder.append(clsName, "");
_builder.append("::s_stateStrings[] = {");
_builder.newLineIfNotEmpty();
@@ -106,7 +106,7 @@ public class StateMachineGen extends GenericStateMachineGenerator {
boolean _isGenerateMSCInstrumentation = _settings.isGenerateMSCInstrumentation();
if (_isGenerateMSCInstrumentation) {
_builder.append("\t");
- _builder.append("DebuggingService::getInstance().addActorState(*this, s_stateStrings[new_state]);");
+ _builder.append("DebuggingService::getInstance().addActorState(*this, s_stateStrings[new_state].c_str());");
_builder.newLine();
}
}
@@ -119,7 +119,7 @@ public class StateMachineGen extends GenericStateMachineGenerator {
_builder.newLine();
_builder.append("\t");
_builder.append("\t");
- _builder.append("std::cout << getInstancePath() << \" -> \" << s_stateStrings[new_state] << std::endl;");
+ _builder.append("std::cout << getInstancePath().c_str() << \" -> \" << s_stateStrings[new_state].c_str() << std::endl;");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
@@ -136,7 +136,7 @@ public class StateMachineGen extends GenericStateMachineGenerator {
StringConcatenation _builder_1 = new StringConcatenation();
{
if ((Main.getSettings().isGenerateMSCInstrumentation() || Main.getSettings().isGenerateWithVerboseOutput())) {
- _builder_1.append("static const std::string s_stateStrings[];");
+ _builder_1.append("static const String s_stateStrings[];");
_builder_1.newLine();
}
}
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.c.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.c.zip
index 54558e292..3ecace8a9 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.c.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.c.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.java.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.java.zip
index 05e4d10a1..acc143640 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.java.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.java.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip
index 7d6c3df14..01b556e8a 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.cpp.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.cpp.zip
index 9692ea254..cd2962219 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.cpp.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.cpp.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zip
index ea4301b99..5df63c0f7 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip
index 3ee2d28f4..1914fe307 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.cpp.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.cpp.zip
index 3e301b4f8..32cf6d8f7 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.cpp.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.cpp.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip
index 5bff1e19b..db59e9965 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.c.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.c.zip
index d370a20f3..24536ada3 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.c.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.c.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.cpp.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.cpp.zip
index e887aca17..79db259db 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.cpp.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.cpp.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.c.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.c.zip
index e29128ff0..56e9239e0 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.c.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.c.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.cpp.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.cpp.zip
index b8f234e73..bad2140fb 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.cpp.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.cpp.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zip
index 919480bf0..a86dfd48d 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zip
Binary files differ
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) {
}
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/RunAllTestCases.cpp b/tests/org.eclipse.etrice.runtime.cpp.tests/src/RunAllTestCases.cpp
index 3a9a7be59..322ca7a2c 100644
--- a/tests/org.eclipse.etrice.runtime.cpp.tests/src/RunAllTestCases.cpp
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/RunAllTestCases.cpp
@@ -10,9 +10,15 @@
*
*******************************************************************************/
-#include <containers/StaticDequeTest.h>
+#include "common/containers/Set.h"
+#include "containers/SetTest.h"
+#include "containers/StaticDequeTest.h"
#include "containers/StaticArrayTest.h"
#include "containers/StaticStringTest.h"
+#include "containers/StringTest.h"
+#include "containers/VectorTest.h"
+#include "containers/PairTest.h"
+#include "containers/MapTest.h"
#include "debugging/MSCFunctionObjectTest.h"
#include "debugging/MSCFilterTest.h"
#include "debugging/MSCLoggerTest.h"
@@ -41,6 +47,21 @@ int main() {
StaticDequeTest dequeTest;
dequeTest.run();
+ StringTest stringTest;
+ stringTest.run();
+
+ VectorTest vectorTest;
+ vectorTest.run();
+
+ SetTest setTest;
+ setTest.run();
+
+ PairTest pairTest;
+ pairTest.run();
+
+ MapTest mapTest;
+ mapTest.run();
+
// Test debugging
MSCFilterTest filterTest;
filterTest.run();
@@ -81,6 +102,15 @@ int main() {
etUnit_close();
+ printf("String allocations %d and deallocations %d\n", etRuntime::String::getNAllocations(), etRuntime::String::getNDeallocations());
+ printf("String creations %d and destructions %d\n", etRuntime::String::getNCreated(), etRuntime::String::getNDestroyed());
+ printf("Vector allocations %d and deallocations %d\n", etRuntime::VectorStats::getNAllocations(), etRuntime::VectorStats::getNDeallocations());
+ printf("Vector creations %d and destructions %d\n", etRuntime::VectorStats::getNCreated(), etRuntime::VectorStats::getNDestroyed());
+ printf("Set creations %d and destructions %d\n", etRuntime::SetStats::getNCreated(), etRuntime::SetStats::getNDestroyed());
+ printf("Map creations %d and destructions %d\n", etRuntime::MapStats::getNCreated(), etRuntime::MapStats::getNDestroyed());
+
+ fflush(stdout);
+
return 0;
}
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/MapTest.cpp b/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/MapTest.cpp
new file mode 100644
index 000000000..21c9cbc89
--- /dev/null
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/MapTest.cpp
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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 "MapTest.h"
+
+#include "common/containers/Map.h"
+#include "common/containers/String.h"
+#include "util/etAssert.h"
+
+using namespace etRuntime;
+
+void MapTest::testConstructors(void) {
+ Map<int, String> m1;
+ EXPECT_TRUE(m_caseId, "map is empty", m1.empty());
+ EXPECT_EQUAL_INT32(m_caseId, "map size is 0", 0, m1.size());
+
+ m1[2] = "two";
+ EXPECT_TRUE(m_caseId, "map is not empty", !m1.empty());
+ EXPECT_EQUAL_INT32(m_caseId, "map size is 1", 1, m1.size());
+
+ // copy constructor
+ Map<int, String> m2(m1);
+ EXPECT_TRUE(m_caseId, "map is not empty", !m2.empty());
+ EXPECT_EQUAL_INT32(m_caseId, "map size is 1", 1, m2.size());
+}
+
+void MapTest::testSettersAndGetters(void) {
+ Map<int, String> m1;
+ m1[2] = "two";
+ m1[1] = "one";
+
+ EXPECT_EQUAL_INT32(m_caseId, "map size is 2", 2, m1.size());
+ EXPECT_TRUE(m_caseId, "map[1]=='one'", m1[1]=="one");
+ EXPECT_TRUE(m_caseId, "map[2]=='two'", m1[2]=="two");
+}
+
+void MapTest::testOperators(void) {
+}
+
+void MapTest::runAllTestCases() {
+ ADD_TESTCASE_CPP(testConstructors)
+ ADD_TESTCASE_CPP(testSettersAndGetters)
+ ADD_TESTCASE_CPP(testOperators)
+}
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/MapTest.h b/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/MapTest.h
new file mode 100644
index 000000000..fceac394e
--- /dev/null
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/MapTest.h
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * 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 SRC_CONTAINERS_MAPTEST_H_
+#define SRC_CONTAINERS_MAPTEST_H_
+
+#include "etUnit/etUnit.h"
+#include "util/etTestSuite.h"
+
+class MapTest : public etTestSuite {
+
+public:
+ MapTest() :
+ etTestSuite("MapTest"){
+ }
+
+protected:
+ void testConstructors(void);
+ void testSettersAndGetters(void);
+ void testOperators(void);
+
+ virtual void runAllTestCases();
+};
+
+
+
+#endif /* SRC_CONTAINERS_MAPTEST_H_ */
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/PairTest.cpp b/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/PairTest.cpp
new file mode 100644
index 000000000..453334af2
--- /dev/null
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/PairTest.cpp
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * 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 "PairTest.h"
+
+#include "common/containers/Pair.h"
+#include "common/containers/String.h"
+#include "util/etAssert.h"
+
+using namespace etRuntime;
+
+void PairTest::testConstructors(void) {
+ Pair<int, int> p1;
+ EXPECT_EQUAL_INT32(m_caseId, "p1.first", 0, p1.first);
+ EXPECT_EQUAL_INT32(m_caseId, "p1.second", 0, p1.second);
+
+ Pair<int, int> p2(1, 2);
+ EXPECT_EQUAL_INT32(m_caseId, "p1.first", 1, p2.first);
+ EXPECT_EQUAL_INT32(m_caseId, "p1.second", 2, p2.second);
+
+ Pair<int, String> p3;
+ EXPECT_EQUAL_INT32(m_caseId, "p1.first", 0, p3.first);
+ EXPECT_TRUE(m_caseId, "p1.second", p3.second=="");
+
+ Pair<int, String> p4(123, "pair");
+ EXPECT_EQUAL_INT32(m_caseId, "p1.first", 123, p4.first);
+ EXPECT_TRUE(m_caseId, "p1.second", p4.second=="pair");
+}
+
+void PairTest::testOperators(void) {
+ Pair<int, int> p1(2,2), p2(1, 1);
+ EXPECT_TRUE(m_caseId, "p1>p2", p1>p2);
+ EXPECT_TRUE(m_caseId, "!p1<p2", !(p1<p2));
+ EXPECT_TRUE(m_caseId, "p1!=p2", p1!=p2);
+
+ p1.first = 1;
+ EXPECT_TRUE(m_caseId, "p1>p2", p1>p2);
+ EXPECT_TRUE(m_caseId, "!p1<p2", !(p1<p2));
+ EXPECT_TRUE(m_caseId, "p1!=p2", p1!=p2);
+
+ p1.second = 1;
+ EXPECT_TRUE(m_caseId, "!p1>p2", !(p1>p2));
+ EXPECT_TRUE(m_caseId, "!p1<p2", !(p1<p2));
+ EXPECT_TRUE(m_caseId, "p1>=p2", p1>=p2);
+ EXPECT_TRUE(m_caseId, "p1<=p2", p1<=p2);
+ EXPECT_TRUE(m_caseId, "p1==p2", p1==p2);
+}
+
+void PairTest::runAllTestCases() {
+ ADD_TESTCASE_CPP(testConstructors)
+ ADD_TESTCASE_CPP(testOperators)
+}
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/PairTest.h b/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/PairTest.h
new file mode 100644
index 000000000..145d1cc4a
--- /dev/null
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/PairTest.h
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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 SRC_CONTAINERS_PAIRTEST_H_
+#define SRC_CONTAINERS_PAIRTEST_H_
+
+#include "etUnit/etUnit.h"
+#include "util/etTestSuite.h"
+
+class PairTest : public etTestSuite {
+
+public:
+ PairTest() :
+ etTestSuite("PairTest"){
+ }
+
+protected:
+ void testConstructors(void);
+ void testOperators(void);
+
+ virtual void runAllTestCases();
+};
+
+
+
+#endif /* SRC_CONTAINERS_PAIRTEST_H_ */
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/SetTest.cpp b/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/SetTest.cpp
new file mode 100644
index 000000000..fbbd1a826
--- /dev/null
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/SetTest.cpp
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * 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 "SetTest.h"
+
+#include "common/containers/Set.h"
+#include "common/messaging/Address.h"
+#include "util/etAssert.h"
+
+using namespace etRuntime;
+
+void SetTest::testConstructors(void) {
+ Set<int> set;
+ EXPECT_TRUE(m_caseId, "set is empty", set.empty());
+ EXPECT_TRUE(m_caseId, "set is empty", set.size() == 0);
+
+ set.insert(1);
+ set.insert(2);
+ set.insert(3);
+ EXPECT_TRUE(m_caseId, "set is not empty", !set.empty());
+ EXPECT_TRUE(m_caseId, "set has size 3", set.size() == 3);
+
+ // copy constructor
+ Set<int> set2(set);
+ EXPECT_TRUE(m_caseId, "set is not empty", !set2.empty());
+ EXPECT_TRUE(m_caseId, "set has size 3", set2.size() == 3);
+}
+
+void SetTest::testSettersAndGetters(void) {
+ Set<int> set;
+
+ set.insert(1);
+ EXPECT_TRUE(m_caseId, "set is not empty", !set.empty());
+ EXPECT_TRUE(m_caseId, "set size is 1", set.size() == 1);
+
+ set.clear();
+ EXPECT_TRUE(m_caseId, "set is empty", set.empty());
+ EXPECT_TRUE(m_caseId, "set is empty", set.size() == 0);
+}
+
+void SetTest::testOperators(void) {
+ Set<int> set1, set2;
+
+ //
+ // comparison with primitive type
+ //
+ set1.insert(1); set2.insert(3);
+ set1.insert(2); set2.insert(1);
+ set1.insert(3); set2.insert(2);
+ EXPECT_TRUE(m_caseId, "sets are equal", set1 == set2);
+
+ Set<Address> set3, set4;
+
+ //
+ // comparison with class
+ //
+ set3.insert(Address(1,2,3)); set4.insert(Address(7,8,9));
+ set3.insert(Address(4,5,6)); set4.insert(Address(1,2,3));
+ set3.insert(Address(7,8,9)); set4.insert(Address(4,5,6));
+ EXPECT_TRUE(m_caseId, "sets are equal", set3 == set4);
+
+ //
+ // find with primitive type
+ //
+ Set<int>::iterator it1;
+ it1 = set1.find(10);
+ EXPECT_TRUE(m_caseId, "value 10 is not found", it1 == set1.end());
+ it1 = set1.find(2);
+ EXPECT_TRUE(m_caseId, "value 2 is found", it1 != set1.end());
+
+ // remove this occurrence
+ set1.erase(it1);
+
+ it1 = set1.find(2);
+ EXPECT_TRUE(m_caseId, "value 2 is NOT found", it1 == set1.end());
+
+ //
+ // find with class
+ //
+ Set<Address>::iterator it3;
+ it3 = set3.find(Address(3,2,1));
+ EXPECT_TRUE(m_caseId, "value Address(3,2,1) is not found", it3 == set3.end());
+ it3 = set3.find(Address(4,5,6));
+ EXPECT_TRUE(m_caseId, "value Address(4,5,6) is found", it3 != set3.end());
+
+ // remove this occurrence
+ set3.erase(it3);
+
+ it3 = set3.find(Address(4,5,6));
+ EXPECT_TRUE(m_caseId, "value 2 is NOT found", it3 == set3.end());
+}
+
+void SetTest::runAllTestCases() {
+ ADD_TESTCASE_CPP(testConstructors)
+ ADD_TESTCASE_CPP(testSettersAndGetters)
+ ADD_TESTCASE_CPP(testOperators)
+}
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/SetTest.h b/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/SetTest.h
new file mode 100644
index 000000000..b76490d58
--- /dev/null
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/SetTest.h
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * 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 SRC_CONTAINERS_SETTEST_H_
+#define SRC_CONTAINERS_SETTEST_H_
+
+#include "etUnit/etUnit.h"
+#include "util/etTestSuite.h"
+
+class SetTest : public etTestSuite {
+
+public:
+ SetTest() :
+ etTestSuite("SetTest"){
+ }
+
+protected:
+ void testConstructors(void);
+ void testSettersAndGetters(void);
+ void testOperators(void);
+
+ virtual void runAllTestCases();
+};
+
+
+
+#endif /* SRC_CONTAINERS_SETTEST_H_ */
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/StringTest.cpp b/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/StringTest.cpp
new file mode 100644
index 000000000..8df849343
--- /dev/null
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/StringTest.cpp
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * 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 "StringTest.h"
+
+#include "common/containers/String.h"
+#include "util/etAssert.h"
+
+using namespace etRuntime;
+
+void StringTest::testConstructors(void) {
+ // default constructors for simple types
+ String string1; // nothing happens, but should not crash
+ String string2("eTrice");
+ String string3(string2); // copy construction for unequal sizes
+
+ EXPECT_EQUAL_INT8(m_caseId, "default string is not 0 at pos 0", 0,
+ (int8)string1[0]);
+ EXPECT_EQUAL_INT8(m_caseId, "value for string2 at pos 2 is wrong", 'r',
+ (int8)string2[2]);
+ EXPECT_EQUAL_INT8(m_caseId, "value for string2 at pos 4 is wrong", 'c',
+ (int8)string2[4]);
+
+ EXPECT_EQUAL_INT8(m_caseId, "copy constructor for string3 wrong", 'e',
+ (int8)string3[0]);
+ EXPECT_EQUAL_INT8(m_caseId, "copy constructor for string3 wrong", 'r',
+ (int8)string3[2]);
+ EXPECT_EQUAL_INT8(m_caseId, "copy constructor for string3 wrong", 'c',
+ (int8)string3[4]);
+}
+
+void StringTest::testSettersAndGetters(void) {
+ String string1("eTrice"); // nothing happens, but should not crash
+
+ // getSize
+ EXPECT_EQUAL_INT8(m_caseId, "length wrong", 6, string1.length());
+
+ // getData
+ EXPECT_EQUAL_INT8(m_caseId, "getData wrong", 'i', (int8)string1[3]);
+}
+
+void StringTest::testOperators(void) {
+ String string1("eTrice"); // nothing happens, but should not crash
+
+ String string2;
+ string2 = string1;
+ EXPECT_TRUE(m_caseId, "strings should be equal", std::strcmp(string1.c_str(), string2.c_str())==0);
+
+ string2 = "ROOM";
+ EXPECT_TRUE(m_caseId, "strings should be equal", std::strcmp("ROOM", string2.c_str())==0);
+
+ String string3("ROOM with ");
+ string3 += "eTrice";
+ EXPECT_TRUE(m_caseId, "strings should be equal", std::strcmp("ROOM with eTrice", string3.c_str())==0);
+
+ String string4("ROOM with ");
+ String string5("eTrice");
+ string4 += string5;
+ EXPECT_TRUE(m_caseId, "strings should be equal", std::strcmp("ROOM with eTrice", string4.c_str())==0);
+
+ String string6("ROOM with ");
+ String string7("eTrice");
+ String string8 = string6 + string7;
+ EXPECT_TRUE(m_caseId, "strings should be equal", std::strcmp("ROOM with eTrice", string8.c_str())==0);
+
+ String string9("ROOM with ");
+ String string10 = string9 + "eTrice";
+ EXPECT_TRUE(m_caseId, "strings should be equal", std::strcmp("ROOM with eTrice", string10.c_str())==0);
+
+ String string11("something");
+ EXPECT_TRUE(m_caseId, "strings should be equal", string11=="something");
+
+ String string12("something");
+ EXPECT_TRUE(m_caseId, "strings should be equal", string11==string12);
+
+ String string13("this is a long string");
+ string13 = "short"; // new contents without re-allocation
+ EXPECT_TRUE(m_caseId, "strings should be equal", string13=="short");
+
+ String string14("aaa");
+ String string15("bbb");
+ EXPECT_TRUE(m_caseId, "strings should be equal", string14.compare("aaa")==0);
+ EXPECT_TRUE(m_caseId, "strings should be equal", string14.compare(string15)<0);
+
+ //
+ // find and substr
+ //
+ String str = "We think in generalities, but we live in details.";
+ // (quoting Alfred N. Whitehead)
+
+ String str2 = str.substr(3, 5); // "think"
+ EXPECT_TRUE(m_caseId, "strings should be equal", str2.compare("think")==0);
+
+ size_t pos = str.find("live"); // position of "live" in str
+ EXPECT_EQUAL_INT32(m_caseId, "pos should be 33", 33, pos);
+
+ String str3 = str.substr(pos); // get from "live" to the end
+ EXPECT_TRUE(m_caseId, "strings should be equal", str3.compare("live in details.")==0);
+
+ String str5 = str.substr(pos, 4); // get "live"
+ EXPECT_TRUE(m_caseId, "strings should be equal", str5.compare("live")==0);
+
+ String str4;
+ str4 += 'a';
+ EXPECT_TRUE(m_caseId, "strings should be equal", str4.compare("a")==0);
+}
+
+void StringTest::runAllTestCases() {
+ ADD_TESTCASE_CPP(testConstructors)
+ ADD_TESTCASE_CPP(testSettersAndGetters)
+ ADD_TESTCASE_CPP(testOperators)
+}
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/StringTest.h b/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/StringTest.h
new file mode 100644
index 000000000..7a7cb4871
--- /dev/null
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/StringTest.h
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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 SRC_CONTAINERS_STRINGTEST_H_
+#define SRC_CONTAINERS_STRINGTEST_H_
+
+#include "etUnit/etUnit.h"
+#include "util/etTestSuite.h"
+
+class StringTest : public etTestSuite {
+
+public:
+ StringTest() :
+ etTestSuite("StringTest"){
+ }
+
+protected:
+ void testConstructors(void);
+ void testSettersAndGetters(void);
+ void testOperators(void);
+
+ virtual void runAllTestCases();
+};
+
+
+#endif /* SRC_CONTAINERS_STRINGTEST_H_ */
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/VectorTest.cpp b/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/VectorTest.cpp
new file mode 100644
index 000000000..fb272cf45
--- /dev/null
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/VectorTest.cpp
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * 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 "VectorTest.h"
+
+#include "common/containers/Vector.h"
+#include "common/messaging/Address.h"
+#include "util/etAssert.h"
+
+using namespace etRuntime;
+
+void VectorTest::testConstructors(void) {
+ Vector<int> vec;
+ EXPECT_TRUE(m_caseId, "vector is empty", vec.empty());
+ EXPECT_TRUE(m_caseId, "vector is empty", vec.size() == 0);
+
+ Vector<Address> vec2(3);
+ EXPECT_TRUE(m_caseId, "vector is not empty", !vec2.empty());
+ EXPECT_TRUE(m_caseId, "vector has size 3", vec2.size() == 3);
+}
+
+void VectorTest::testSettersAndGetters(void) {
+ Vector<int> vec;
+
+ vec.push_back(1);
+ EXPECT_TRUE(m_caseId, "vector is not empty", !vec.empty());
+ EXPECT_TRUE(m_caseId, "vector size is 1", vec.size() == 1);
+ EXPECT_TRUE(m_caseId, "element 0 is 1", vec[0] == 1);
+
+ vec[0] = 2;
+ EXPECT_TRUE(m_caseId, "element 0 is 2", vec[0] == 2);
+
+ vec[0] = 1;
+ EXPECT_TRUE(m_caseId, "element 0 is 1", vec[0] == 1);
+ vec.push_back(2);
+ EXPECT_TRUE(m_caseId, "vector is not empty", !vec.empty());
+ EXPECT_TRUE(m_caseId, "vector size is 2", vec.size() == 2);
+ EXPECT_TRUE(m_caseId, "element 1 is 2", vec[1] == 2);
+}
+
+void VectorTest::testOperators(void) {
+ Vector<int> vec1, vec2;
+
+ //
+ // comparison
+ //
+ vec1.push_back(1); vec2.push_back(1);
+ vec1.push_back(2); vec2.push_back(2);
+ vec1.push_back(3); vec2.push_back(3);
+ EXPECT_TRUE(m_caseId, "vectors are equal", vec1 == vec2);
+
+ //
+ // iterators
+ //
+ Vector<int>::iterator it1 = vec1.begin();
+ EXPECT_TRUE(m_caseId, "element at iterator position is 1", *it1 == 1);
+ EXPECT_TRUE(m_caseId, "element at iterator position is 2", *(++it1) == 2);
+
+ it1 = vec1.erase(it1);
+ EXPECT_EQUAL_INT32(m_caseId, "new vector size is 2", 2, vec1.size());
+ EXPECT_EQUAL_INT32(m_caseId, "element at iterator position is 3", 3, *it1);
+ EXPECT_TRUE(m_caseId, "incremented iterator is at end", ++it1 == vec1.end());
+
+ EXPECT_TRUE(m_caseId, "vectors are not equal", vec1 != vec2);
+
+ //
+ // front and back
+ //
+ EXPECT_EQUAL_INT32(m_caseId, "element at front is 1", 1, vec2.front());
+ EXPECT_EQUAL_INT32(m_caseId, "element at front is 3", 3, vec2.back());
+}
+
+void VectorTest::runAllTestCases() {
+ ADD_TESTCASE_CPP(testConstructors)
+ ADD_TESTCASE_CPP(testSettersAndGetters)
+ ADD_TESTCASE_CPP(testOperators)
+}
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/VectorTest.h b/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/VectorTest.h
new file mode 100644
index 000000000..d997a9cc3
--- /dev/null
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/containers/VectorTest.h
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * 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 SRC_CONTAINERS_VECTORTEST_H_
+#define SRC_CONTAINERS_VECTORTEST_H_
+
+#include "etUnit/etUnit.h"
+#include "util/etTestSuite.h"
+
+class VectorTest : public etTestSuite {
+
+public:
+ VectorTest() :
+ etTestSuite("VectorTest"){
+ }
+
+protected:
+ void testConstructors(void);
+ void testSettersAndGetters(void);
+ void testOperators(void);
+
+ virtual void runAllTestCases();
+};
+
+
+
+#endif /* SRC_CONTAINERS_VECTORTEST_H_ */
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/debugging/DebuggingServiceTest.cpp b/tests/org.eclipse.etrice.runtime.cpp.tests/src/debugging/DebuggingServiceTest.cpp
index 7a53e2fc9..b04d03034 100644
--- a/tests/org.eclipse.etrice.runtime.cpp.tests/src/debugging/DebuggingServiceTest.cpp
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/debugging/DebuggingServiceTest.cpp
@@ -16,6 +16,7 @@
#include "common/messaging/RTServices.h"
#include "common/messaging/StaticMessageMemory.h"
#include "etUnit/etUnit.h"
+#include <iostream>
using namespace etRuntime;
@@ -61,47 +62,54 @@ void DebuggingServiceTest::testLogging() {
RTServices::getInstance().getMsgSvcCtrl().stop();
const char* failMsg = "DebuggingServiceTest failed";
- std::list<std::string>& result = dbgSvc.getAsyncLogger().getCommandList();
+ Vector<String>& result = dbgSvc.getAsyncLogger().getCommandList();
+
+ typedef Vector<String> CmdList;
+ for (CmdList::iterator it=result.begin(); it!=result.end(); ++it) {
+ std::cout << (*it).c_str() << std::endl;
+ }
+
+ Vector<String>::iterator it = result.begin();
EXPECT_TRUE(m_caseId, failMsg,
- !result.front().compare(
+ 0==(*it).compare(
"\t/TestSubSystem (!) /TestSubSystem/TestActor1 "));
- result.pop_front();
+ ++it;
EXPECT_TRUE(m_caseId, failMsg,
- !result.front().compare(
+ 0==(*it).compare(
"\t/TestSubSystem (!) /TestSubSystem/TestActor2 "));
- result.pop_front();
+ ++it;
EXPECT_TRUE(m_caseId, failMsg,
- !result.front().compare(
+ 0==(*it).compare(
"\t/TestSubSystem/TestActor1 (!) /TestSubSystem/TestActor1/SubActor "));
- result.pop_front();
+ ++it;
EXPECT_TRUE(m_caseId, failMsg,
- !result.front().compare(
+ 0==(*it).compare(
"\t/TestSubSystem/TestActor1 >-- /TestSubSystem/TestActor2 MessageAsync"));
- result.pop_front();
+ ++it;
EXPECT_TRUE(m_caseId, failMsg,
- !result.front().compare(
+ 0==(*it).compare(
"\t/TestSubSystem/TestActor1 --> /TestSubSystem/TestActor2 MessageAsync"));
- result.pop_front();
+ ++it;
EXPECT_TRUE(m_caseId, failMsg,
- !result.front().compare(
+ 0==(*it).compare(
"\t/TestSubSystem/TestActor1 ==> /TestSubSystem/TestActor2 MessageSyncCall"));
- result.pop_front();
+ ++it;
EXPECT_TRUE(m_caseId, failMsg,
- !result.front().compare(
+ 0==(*it).compare(
"\t/TestSubSystem/TestActor1 <== /TestSubSystem/TestActor2 MessageSyncReturn"));
- result.pop_front();
+ ++it;
EXPECT_TRUE(m_caseId, failMsg,
- !result.front().compare(
+ 0==(*it).compare(
"\t/TestSubSystem/TestActor1 >>> TestState"));
- result.pop_front();
+ ++it;
EXPECT_TRUE(m_caseId, failMsg,
- !result.front().compare(
+ 0==(*it).compare(
"\t/TestSubSystem (X) /TestSubSystem/TestActor1 "));
- result.pop_front();
+ ++it;
EXPECT_TRUE(m_caseId, failMsg,
- !result.front().compare("# This is a comment"));
- result.pop_front();
+ 0==(*it).compare("# This is a comment"));
+ ++it;
}
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/debugging/DebuggingServiceTest.h b/tests/org.eclipse.etrice.runtime.cpp.tests/src/debugging/DebuggingServiceTest.h
index 44f19d517..212d38e8f 100644
--- a/tests/org.eclipse.etrice.runtime.cpp.tests/src/debugging/DebuggingServiceTest.h
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/debugging/DebuggingServiceTest.h
@@ -34,7 +34,7 @@ protected:
class ActorClass: public ActorClassBase {
public:
- ActorClass(IRTObject* parent, const std::string& name) :
+ ActorClass(IRTObject* parent, const String& name) :
ActorClassBase(parent, name) {
}
@@ -46,7 +46,7 @@ public:
class SubSystemClass: public SubSystemClassBase {
public:
- SubSystemClass(IRTObject* parent, std::string name) :
+ SubSystemClass(IRTObject* parent, String name) :
SubSystemClassBase(parent, name) {
}
@@ -63,7 +63,7 @@ public:
class Port: public PortBase {
public:
- Port(IInterfaceItemOwner* owner, const std::string& name) :
+ Port(IInterfaceItemOwner* owner, const String& name) :
PortBase(owner, name, 0) {
}
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/debugging/MSCLoggerTest.cpp b/tests/org.eclipse.etrice.runtime.cpp.tests/src/debugging/MSCLoggerTest.cpp
index ea1ae065b..01be8e936 100644
--- a/tests/org.eclipse.etrice.runtime.cpp.tests/src/debugging/MSCLoggerTest.cpp
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/debugging/MSCLoggerTest.cpp
@@ -13,8 +13,6 @@
#include "MSCLoggerTest.h"
#include "common/debugging/MSCLogger.h"
#include "etUnit/etUnit.h"
-#include <stdio.h>
-#include <string.h>
using namespace etRuntime;
@@ -36,38 +34,39 @@ void MSCLoggerTest::testLogger() {
logger.close();
const char* failMsg = "MSCLoggerTest failed";
- std::list<std::string>& result = logger.getCommandList();
+ Vector<String>& result = logger.getCommandList();
+ Vector<String>::iterator it = result.begin();
EXPECT_TRUE(m_caseId, failMsg,
- !result.front().compare("\tSource >-- Target MessageAsync"));
- result.pop_front();
+ !(*it).compare("\tSource >-- Target MessageAsync"));
+ ++it;
EXPECT_TRUE(m_caseId, failMsg,
- !result.front().compare("\tSource --> Target MessageAsync"));
- result.pop_front();
+ !(*it).compare("\tSource --> Target MessageAsync"));
+ ++it;
EXPECT_TRUE(m_caseId, failMsg,
- !result.front().compare("\tSource ==> Target MessageSyncCall"));
- result.pop_front();
+ !(*it).compare("\tSource ==> Target MessageSyncCall"));
+ ++it;
EXPECT_TRUE(m_caseId, failMsg,
- !result.front().compare("\tSource <== Target MessageSyncReturn"));
- result.pop_front();
+ !(*it).compare("\tSource <== Target MessageSyncReturn"));
+ ++it;
EXPECT_TRUE(m_caseId, failMsg,
- !result.front().compare("\tSource (!) Target "));
- result.pop_front();
+ !(*it).compare("\tSource (!) Target "));
+ ++it;
EXPECT_TRUE(m_caseId, failMsg,
- !result.front().compare("\tSource (X) Target "));
- result.pop_front();
+ !(*it).compare("\tSource (X) Target "));
+ ++it;
EXPECT_TRUE(m_caseId, failMsg,
- !result.front().compare("\tActor note: Note"));
- result.pop_front();
+ !(*it).compare("\tActor note: Note"));
+ ++it;
EXPECT_TRUE(m_caseId, failMsg,
- !result.front().compare("\tSource (!) Target "));
- result.pop_front();
+ !(*it).compare("\tSource (!) Target "));
+ ++it;
EXPECT_TRUE(m_caseId, failMsg,
- !result.front().compare("\tActor >>> State"));
- result.pop_front();
+ !(*it).compare("\tActor >>> State"));
+ ++it;
EXPECT_TRUE(m_caseId, failMsg,
- !result.front().compare("# This is a comment"));
- result.pop_front();
+ !(*it).compare("# This is a comment"));
+ ++it;
}
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageDispatcherTest.cpp b/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageDispatcherTest.cpp
index 730a3a7d9..0c04fd125 100644
--- a/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageDispatcherTest.cpp
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageDispatcherTest.cpp
@@ -22,7 +22,7 @@ void MessageDispatcherTest::testConstructors() {
const char *failMsg = "MessageDispatcher constructor test failed";
- // Test constructor MessageDispatcher(IRTObject* parent, const Address& addr, const std::string& name)
+ // Test constructor MessageDispatcher(IRTObject* parent, const Address& addr, const String& name)
Address addr(1, 2, 3);
MessageDispatcher msgDisp(NULL, addr, "TestMessageDispatcher");
EXPECT_TRUE(m_caseId, failMsg, addr == msgDisp.getAddress());
@@ -41,16 +41,26 @@ void MessageDispatcherTest::testFreeAddresses() {
Address(1, 2, 5) == msgDisp.getFreeAddress());
EXPECT_TRUE(m_caseId, failMsg,
Address(1, 2, 6) == msgDisp.getFreeAddress());
+
+ // free one address
msgDisp.freeAddress(Address(1, 2, 5));
+
+ // get it as next address
EXPECT_TRUE(m_caseId, failMsg,
Address(1, 2, 5) == msgDisp.getFreeAddress());
+
+ // free two addresses
msgDisp.freeAddress(Address(1, 2, 4));
msgDisp.freeAddress(Address(1, 2, 6));
- EXPECT_TRUE(m_caseId, failMsg,
- Address(1, 2, 4) == msgDisp.getFreeAddress());
+
+ // get them in reverse order
EXPECT_TRUE(m_caseId, failMsg,
Address(1, 2, 6) == msgDisp.getFreeAddress());
EXPECT_TRUE(m_caseId, failMsg,
+ Address(1, 2, 4) == msgDisp.getFreeAddress());
+
+ // no freed address left: get a fresh one
+ EXPECT_TRUE(m_caseId, failMsg,
Address(1, 2, 7) == msgDisp.getFreeAddress());
}
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageDispatcherTest.h b/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageDispatcherTest.h
index 072eb4f35..beab56e2a 100644
--- a/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageDispatcherTest.h
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageDispatcherTest.h
@@ -34,9 +34,9 @@ protected:
class SimpleMessageReceiver: public etRuntime::RTObject,
public etRuntime::IMessageReceiver {
public:
- SimpleMessageReceiver(IRTObject *parent, const std::string& name,
+ SimpleMessageReceiver(IRTObject *parent, const etRuntime::String& name,
const etRuntime::Address& address) :
- RTObject(parent, name), m_address(address), m_lastMessage(NULL) {
+ RTObject(parent, name), m_address(address), m_lastMessage(NULL) {
}
void receive(const etRuntime::Message* msg) {
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageServiceTest.h b/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageServiceTest.h
index cccf480b7..57e00d7b8 100644
--- a/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageServiceTest.h
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageServiceTest.h
@@ -54,7 +54,7 @@ private:
class MessageCounter: public etRuntime::RTObject,
public etRuntime::IMessageReceiver {
public:
- MessageCounter(IRTObject *parent, const std::string &name,
+ MessageCounter(IRTObject *parent, const etRuntime::String &name,
const etRuntime::Address &address) :
RTObject(parent, name), m_counter(0), m_address(address) {
}
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/RTObjectTest.cpp b/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/RTObjectTest.cpp
index f84456fc5..51ef8bf0e 100644
--- a/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/RTObjectTest.cpp
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/RTObjectTest.cpp
@@ -22,7 +22,7 @@ void RTObjectTest::testConstructors() {
const char* failMsg = "RTObject constructor test failed";
- // Test constructor RTObject(IRTObject* parent, const std::string& name)
+ // Test constructor RTObject(IRTObject* parent, const String& name)
RTObject* rto1 = new RTObject(NULL, "grandparent");
RTObject* rto2 = new RTObject(rto1, "parent");
RTObject* rto3 = new RTObject(rto2, "child1");
@@ -35,7 +35,7 @@ void RTObjectTest::testConstructors() {
EXPECT_TRUE(m_caseId, failMsg,
!rto1->getInstancePath().compare(
- IRTObject::PATH_DELIM + std::string("grandparent")));
+ IRTObject::PATH_DELIM + String("grandparent")));
EXPECT_TRUE(m_caseId, failMsg,
!rto2->getInstancePath().compare(
rto1->getInstancePath() + IRTObject::PATH_DELIM + "parent"));
@@ -48,7 +48,7 @@ void RTObjectTest::testConstructors() {
EXPECT_TRUE(m_caseId, failMsg,
!rto1->getInstancePathName().compare(
- IRTObject::PATHNAME_DELIM + std::string("grandparent")));
+ IRTObject::PATHNAME_DELIM + String("grandparent")));
EXPECT_TRUE(m_caseId, failMsg,
!rto2->getInstancePathName().compare(
rto1->getInstancePathName() + IRTObject::PATHNAME_DELIM
@@ -62,10 +62,10 @@ void RTObjectTest::testConstructors() {
rto2->getInstancePathName() + IRTObject::PATHNAME_DELIM
+ "child2"));
- std::vector<IRTObject*> children1 = rto1->getChildren();
- std::vector<IRTObject*> children2 = rto2->getChildren();
- std::vector<IRTObject*> children3 = rto3->getChildren();
- std::vector<IRTObject*> children4 = rto4->getChildren();
+ IRTObject::ChildList children1 = rto1->getChildren();
+ IRTObject::ChildList children2 = rto2->getChildren();
+ IRTObject::ChildList children3 = rto3->getChildren();
+ IRTObject::ChildList children4 = rto4->getChildren();
IRTObject *child1 = children2.front();
IRTObject *child2 = children2.back();
EXPECT_EQUAL_PTR(m_caseId, failMsg, rto2, children1.back());
@@ -115,10 +115,10 @@ void RTObjectTest::testGetters() {
EXPECT_TRUE(m_caseId, failMsg, !rto.getName().compare("test"));
EXPECT_TRUE(m_caseId, failMsg,
!rto.getInstancePath().compare(
- IRTObject::PATH_DELIM + std::string("test")));
+ IRTObject::PATH_DELIM + String("test")));
EXPECT_TRUE(m_caseId, failMsg,
!rto.getInstancePathName().compare(
- IRTObject::PATHNAME_DELIM + std::string("test")));
+ IRTObject::PATHNAME_DELIM + String("test")));
EXPECT_EQUAL_INT16(m_caseId, failMsg, 0, rto.getChildren().size());
EXPECT_EQUAL_PTR(m_caseId, failMsg, NULL, rto.getParent());
EXPECT_EQUAL_PTR(m_caseId, failMsg, &rto, rto.getRoot());

Back to the top