Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging')
-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
19 files changed, 163 insertions, 125 deletions
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

Back to the top