All public inline functions arn't anymore inline
authorPatrick Sattler <sattler@itestra.de>
Fri, 7 Feb 2014 10:02:27 +0000 (11:02 +0100)
committerStefan Laner <laner@itestra.de>
Mon, 3 Mar 2014 10:27:37 +0000 (11:27 +0100)
 - methods with templates excluded

Change-Id: I9e2abd0b1015781a4d27c9070fcabb18786dbb88

15 files changed:
Makefile.am
src/CommonAPI/AttributeExtension.h
src/CommonAPI/Event.h
src/CommonAPI/Factory.cpp [new file with mode: 0644]
src/CommonAPI/Factory.h
src/CommonAPI/Factory.hpp
src/CommonAPI/InputStream.cpp [new file with mode: 0644]
src/CommonAPI/InputStream.h
src/CommonAPI/MainLoopContext.cpp [new file with mode: 0644]
src/CommonAPI/MainLoopContext.h
src/CommonAPI/Runtime.cpp
src/CommonAPI/SerializableVariant.h
src/CommonAPI/types.h
src/CommonAPI/utils.cpp [new file with mode: 0644]
src/CommonAPI/utils.h

index 63ef182..1c70d53 100644 (file)
@@ -37,7 +37,11 @@ libCommonAPI_la_SOURCES = \
         src/CommonAPI/Runtime.cpp \
         src/CommonAPI/Configuration.cpp \
         src/CommonAPI/ServicePublisher.cpp \
-        src/CommonAPI/ContainerUtils.cpp
+        src/CommonAPI/ContainerUtils.cpp \
+        src/CommonAPI/MainLoopContext.cpp \
+        src/CommonAPI/InputStream.cpp \
+        src/CommonAPI/Factory.cpp \
+        src/CommonAPI/utils.cpp
 
 CommonAPI_includedir=$(includedir)/CommonAPI-${COMMONAPI_API_HEADER_VERSION}/CommonAPI
 CommonAPI_include_HEADERS = \
index d4c8075..4cea9b1 100644 (file)
@@ -25,7 +25,7 @@ namespace CommonAPI {
 template<typename _AttributeType>
 class AttributeExtension {
  public:
-    inline _AttributeType& getBaseAttribute() {
+    _AttributeType& getBaseAttribute() {
         return baseAttribute_;
     }
 
index 9cac1dc..3d059b2 100644 (file)
@@ -53,7 +53,7 @@ public:
      * @param listener A listener to be added
      * @return A token identifying this subscription
      */
-    virtual inline Subscription subscribe(Listener listener);
+    virtual Subscription subscribe(Listener listener);
 
     /**
      * \brief Subscribe a cancellable listener to this event
diff --git a/src/CommonAPI/Factory.cpp b/src/CommonAPI/Factory.cpp
new file mode 100644 (file)
index 0000000..bc1d696
--- /dev/null
@@ -0,0 +1,16 @@
+/* Copyright (C) 2013 BMW Group
+ * Author: Manfred Bathelt (manfred.bathelt@bmw.de)
+ * Author: Juergen Gehring (juergen.gehring@bmw.de)
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "Factory.h"
+
+namespace CommonAPI {
+
+std::shared_ptr<Runtime> Factory::getRuntime() {
+    return runtime_;
+}
+
+} // namespace CommonAPI
index 4a7c729..3760953 100644 (file)
@@ -185,7 +185,7 @@ class Factory {
      *
      * @return the Runtime
      */
-    inline std::shared_ptr<Runtime> getRuntime();
+    std::shared_ptr<Runtime> getRuntime();
 
     /**
      * \brief Register a service stub under a specified address
index 8884632..0804996 100644 (file)
@@ -39,10 +39,6 @@ Factory::buildProxyWithDefaultAttributeExtension(const std::string& serviceAddre
     return buildProxyWithDefaultAttributeExtension<_ProxyClass, _AttributeExtension>(participantId, serviceName, domain);
 }
 
-inline std::shared_ptr<Runtime> Factory::getRuntime() {
-    return runtime_;
-}
-
 template<typename _Stub>
 COMMONAPI_DEPRECATED bool Factory::registerService(std::shared_ptr<_Stub> stub,
                      const std::string& participantId,
diff --git a/src/CommonAPI/InputStream.cpp b/src/CommonAPI/InputStream.cpp
new file mode 100644 (file)
index 0000000..42dbec8
--- /dev/null
@@ -0,0 +1,77 @@
+/* Copyright (C) 2013 BMW Group
+ * Author: Manfred Bathelt (manfred.bathelt@bmw.de)
+ * Author: Juergen Gehring (juergen.gehring@bmw.de)
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "InputStream.h"
+
+namespace CommonAPI {
+
+InputStream& operator>>(InputStream& inputStream, bool& boolValue) {
+    return inputStream.readValue(boolValue);
+}
+
+InputStream& operator>>(InputStream& inputStream, int8_t& int8Value) {
+    return inputStream.readValue(int8Value);
+}
+
+InputStream& operator>>(InputStream& inputStream, int16_t& int16Value) {
+    return inputStream.readValue(int16Value);
+}
+
+InputStream& operator>>(InputStream& inputStream, int32_t& int32Value) {
+    return inputStream.readValue(int32Value);
+}
+
+InputStream& operator>>(InputStream& inputStream, int64_t& int64Value) {
+    return inputStream.readValue(int64Value);
+}
+
+InputStream& operator>>(InputStream& inputStream, uint8_t& uint8Value) {
+    return inputStream.readValue(uint8Value);
+}
+
+InputStream& operator>>(InputStream& inputStream, uint16_t& uint16Value) {
+    return inputStream.readValue(uint16Value);
+}
+
+InputStream& operator>>(InputStream& inputStream, uint32_t& uint32Value) {
+    return inputStream.readValue(uint32Value);
+}
+
+InputStream& operator>>(InputStream& inputStream, uint64_t& uint64Value) {
+    return inputStream.readValue(uint64Value);
+}
+
+InputStream& operator>>(InputStream& inputStream, float& floatValue) {
+    return inputStream.readValue(floatValue);
+}
+
+InputStream& operator>>(InputStream& inputStream, double& doubleValue) {
+    return inputStream.readValue(doubleValue);
+}
+
+InputStream& operator>>(InputStream& inputStream, std::string& stringValue) {
+    return inputStream.readValue(stringValue);
+}
+
+InputStream& operator>>(InputStream& inputStream, Version& versionValue) {
+    return inputStream.readVersionValue(versionValue);
+}
+
+InputStream& operator>>(InputStream& inputStream, SerializableStruct& serializableStruct) {
+    inputStream.beginReadSerializableStruct(serializableStruct);
+    serializableStruct.readFromInputStream(inputStream);
+    inputStream.endReadSerializableStruct(serializableStruct);
+
+    return inputStream;
+}
+
+InputStream& operator>>(InputStream& inputStream, SerializableVariant& serializableVariant) {
+    inputStream.readSerializableVariant(serializableVariant);
+    return inputStream;
+}
+
+}
index a1987f2..786a991 100644 (file)
@@ -61,7 +61,7 @@ public:
     virtual InputStream& readEnumValue(uint64_t& uint64BackingTypeValue) = 0;
 
     template<typename _EnumBackingType, typename _EnumType>
-    inline InputStream& readEnumValue(_EnumType& enumValue);
+    InputStream& readEnumValue(_EnumType& enumValue);
 
     virtual InputStream& readVersionValue(Version& versionValue) = 0;
 
@@ -126,65 +126,33 @@ InputStream& InputStream::readEnumValue(_EnumType& enumValue) {
     return *this;
 }
 
-inline InputStream& operator>>(InputStream& inputStream, bool& boolValue) {
-    return inputStream.readValue(boolValue);
-}
+InputStream& operator>>(InputStream& inputStream, bool& boolValue);
 
-inline InputStream& operator>>(InputStream& inputStream, int8_t& int8Value) {
-    return inputStream.readValue(int8Value);
-}
+InputStream& operator>>(InputStream& inputStream, int8_t& int8Value);
 
-inline InputStream& operator>>(InputStream& inputStream, int16_t& int16Value) {
-    return inputStream.readValue(int16Value);
-}
+InputStream& operator>>(InputStream& inputStream, int16_t& int16Value);
 
-inline InputStream& operator>>(InputStream& inputStream, int32_t& int32Value) {
-    return inputStream.readValue(int32Value);
-}
+InputStream& operator>>(InputStream& inputStream, int32_t& int32Value);
 
-inline InputStream& operator>>(InputStream& inputStream, int64_t& int64Value) {
-    return inputStream.readValue(int64Value);
-}
+InputStream& operator>>(InputStream& inputStream, int64_t& int64Value);
 
-inline InputStream& operator>>(InputStream& inputStream, uint8_t& uint8Value) {
-    return inputStream.readValue(uint8Value);
-}
-
-inline InputStream& operator>>(InputStream& inputStream, uint16_t& uint16Value) {
-    return inputStream.readValue(uint16Value);
-}
+InputStream& operator>>(InputStream& inputStream, uint8_t& uint8Value);
 
-inline InputStream& operator>>(InputStream& inputStream, uint32_t& uint32Value) {
-    return inputStream.readValue(uint32Value);
-}
+InputStream& operator>>(InputStream& inputStream, uint16_t& uint16Value);
 
-inline InputStream& operator>>(InputStream& inputStream, uint64_t& uint64Value) {
-    return inputStream.readValue(uint64Value);
-}
+InputStream& operator>>(InputStream& inputStream, uint32_t& uint32Value);
 
-inline InputStream& operator>>(InputStream& inputStream, float& floatValue) {
-    return inputStream.readValue(floatValue);
-}
+InputStream& operator>>(InputStream& inputStream, uint64_t& uint64Value);
 
-inline InputStream& operator>>(InputStream& inputStream, double& doubleValue) {
-    return inputStream.readValue(doubleValue);
-}
+InputStream& operator>>(InputStream& inputStream, float& floatValue);
 
-inline InputStream& operator>>(InputStream& inputStream, std::string& stringValue) {
-    return inputStream.readValue(stringValue);
-}
+InputStream& operator>>(InputStream& inputStream, double& doubleValue);
 
-inline InputStream& operator>>(InputStream& inputStream, Version& versionValue) {
-    return inputStream.readVersionValue(versionValue);
-}
+InputStream& operator>>(InputStream& inputStream, std::string& stringValue);
 
-inline InputStream& operator>>(InputStream& inputStream, SerializableStruct& serializableStruct) {
-    inputStream.beginReadSerializableStruct(serializableStruct);
-    serializableStruct.readFromInputStream(inputStream);
-    inputStream.endReadSerializableStruct(serializableStruct);
+InputStream& operator>>(InputStream& inputStream, Version& versionValue);
 
-    return inputStream;
-}
+InputStream& operator>>(InputStream& inputStream, SerializableStruct& serializableStruct);
 
 template<typename _SerializablePolymorphicStructType>
 typename std::enable_if<std::is_base_of<SerializablePolymorphicStruct, _SerializablePolymorphicStructType>::value,
@@ -207,10 +175,7 @@ operator>>(InputStream& inputStream,
     return inputStream;
 }
 
-inline InputStream& operator>>(InputStream& inputStream, SerializableVariant& serializableVariant) {
-    inputStream.readSerializableVariant(serializableVariant);
-    return inputStream;
-}
+InputStream& operator>>(InputStream& inputStream, SerializableVariant& serializableVariant);
 
 template<typename _VectorElementType>
 class InputStreamGenericTypeVectorHelper {
diff --git a/src/CommonAPI/MainLoopContext.cpp b/src/CommonAPI/MainLoopContext.cpp
new file mode 100644 (file)
index 0000000..b13cd89
--- /dev/null
@@ -0,0 +1,99 @@
+/* Copyright (C) 2013 BMW Group
+ * Author: Manfred Bathelt (manfred.bathelt@bmw.de)
+ * Author: Juergen Gehring (juergen.gehring@bmw.de)
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "MainLoopContext.h"
+
+
+namespace CommonAPI {
+
+int64_t getCurrentTimeInMs() {
+   return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count();
+}
+
+DispatchSourceListenerSubscription MainLoopContext::subscribeForDispatchSources(DispatchSourceAddedCallback dispatchAddedCallback, DispatchSourceRemovedCallback dispatchRemovedCallback) {
+    dispatchSourceListeners_.emplace_front(dispatchAddedCallback, dispatchRemovedCallback);
+    return dispatchSourceListeners_.begin();
+}
+
+WatchListenerSubscription MainLoopContext::subscribeForWatches(WatchAddedCallback watchAddedCallback, WatchRemovedCallback watchRemovedCallback) {
+    watchListeners_.emplace_front(watchAddedCallback, watchRemovedCallback);
+    return watchListeners_.begin();
+}
+
+TimeoutSourceListenerSubscription MainLoopContext::subscribeForTimeouts(TimeoutSourceAddedCallback timeoutAddedCallback, TimeoutSourceRemovedCallback timeoutRemovedCallback) {
+    timeoutSourceListeners_.emplace_front(timeoutAddedCallback, timeoutRemovedCallback);
+    return timeoutSourceListeners_.begin();
+}
+
+WakeupListenerSubscription MainLoopContext::subscribeForWakeupEvents(WakeupCallback wakeupCallback) {
+    wakeupListeners_.emplace_front(wakeupCallback);
+    return wakeupListeners_.begin();
+}
+
+void MainLoopContext::unsubscribeForDispatchSources(DispatchSourceListenerSubscription subscription) {
+    dispatchSourceListeners_.erase(subscription);
+}
+
+void MainLoopContext::unsubscribeForWatches(WatchListenerSubscription subscription) {
+    watchListeners_.erase(subscription);
+}
+
+void MainLoopContext::unsubscribeForTimeouts(TimeoutSourceListenerSubscription subscription) {
+    timeoutSourceListeners_.erase(subscription);
+}
+
+void MainLoopContext::unsubscribeForWakeupEvents(WakeupListenerSubscription subscription) {
+    wakeupListeners_.erase(subscription);
+}
+
+void MainLoopContext::registerDispatchSource(DispatchSource* dispatchSource, const DispatchPriority dispatchPriority) {
+    for(auto listener = dispatchSourceListeners_.begin(); listener != dispatchSourceListeners_.end(); ++listener) {
+        listener->first(dispatchSource, dispatchPriority);
+    }
+}
+
+void MainLoopContext::deregisterDispatchSource(DispatchSource* dispatchSource) {
+    for(auto listener = dispatchSourceListeners_.begin(); listener != dispatchSourceListeners_.end(); ++listener) {
+        listener->second(dispatchSource);
+    }
+}
+
+void MainLoopContext::registerWatch(Watch* watch, const DispatchPriority dispatchPriority) {
+    for(auto listener = watchListeners_.begin(); listener != watchListeners_.end(); ++listener) {
+        listener->first(watch, dispatchPriority);
+    }
+}
+
+void MainLoopContext::deregisterWatch(Watch* watch) {
+    for(auto listener = watchListeners_.begin(); listener != watchListeners_.end(); ++listener) {
+        listener->second(watch);
+    }
+}
+
+void MainLoopContext::registerTimeoutSource(Timeout* timeoutEvent, const DispatchPriority dispatchPriority) {
+    for(auto listener = timeoutSourceListeners_.begin(); listener != timeoutSourceListeners_.end(); ++listener) {
+        listener->first(timeoutEvent, dispatchPriority);
+    }
+}
+
+void MainLoopContext::deregisterTimeoutSource(Timeout* timeoutEvent) {
+    for(auto listener = timeoutSourceListeners_.begin(); listener != timeoutSourceListeners_.end(); ++listener) {
+        listener->second(timeoutEvent);
+    }
+}
+
+void MainLoopContext::wakeup() {
+    for(auto listener = wakeupListeners_.begin(); listener != wakeupListeners_.end(); ++listener) {
+        (*listener)();
+    }
+}
+
+bool MainLoopContext::isInitialized() {
+    return dispatchSourceListeners_.size() > 0 || watchListeners_.size() > 0;
+}
+
+} //Namespace CommonAPI
index 6949c0b..3c4e7c1 100644 (file)
 #include <list>
 #include <functional>
 
-
 namespace CommonAPI {
 
-
-
-
 enum class DispatchPriority {
     VERY_HIGH,
     HIGH,
@@ -46,9 +42,7 @@ enum class DispatchPriority {
 };
 
 
-inline int64_t getCurrentTimeInMs() {
-   return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count();
-}
+int64_t getCurrentTimeInMs();
 
 
 /**
@@ -206,125 +200,77 @@ class MainLoopContext {
     /**
      * \brief Registers for all DispatchSources that are added or removed.
      */
-    inline DispatchSourceListenerSubscription subscribeForDispatchSources(DispatchSourceAddedCallback dispatchAddedCallback, DispatchSourceRemovedCallback dispatchRemovedCallback) {
-        dispatchSourceListeners_.emplace_front(dispatchAddedCallback, dispatchRemovedCallback);
-        return dispatchSourceListeners_.begin();
-    }
+    DispatchSourceListenerSubscription subscribeForDispatchSources(DispatchSourceAddedCallback dispatchAddedCallback, DispatchSourceRemovedCallback dispatchRemovedCallback);
 
     /**
      * \brief Registers for all Watches that are added or removed.
      */
-    inline WatchListenerSubscription subscribeForWatches(WatchAddedCallback watchAddedCallback, WatchRemovedCallback watchRemovedCallback) {
-        watchListeners_.emplace_front(watchAddedCallback, watchRemovedCallback);
-        return watchListeners_.begin();
-    }
+    WatchListenerSubscription subscribeForWatches(WatchAddedCallback watchAddedCallback, WatchRemovedCallback watchRemovedCallback);
 
     /**
      * \brief Registers for all Timeouts that are added or removed.
      */
-    inline TimeoutSourceListenerSubscription subscribeForTimeouts(TimeoutSourceAddedCallback timeoutAddedCallback, TimeoutSourceRemovedCallback timeoutRemovedCallback) {
-        timeoutSourceListeners_.emplace_front(timeoutAddedCallback, timeoutRemovedCallback);
-        return timeoutSourceListeners_.begin();
-    }
+    TimeoutSourceListenerSubscription subscribeForTimeouts(TimeoutSourceAddedCallback timeoutAddedCallback, TimeoutSourceRemovedCallback timeoutRemovedCallback);
 
     /**
      * \brief Registers for all Wakeup-Events that need to interrupt a call to "poll".
      */
-    inline WakeupListenerSubscription subscribeForWakeupEvents(WakeupCallback wakeupCallback) {
-        wakeupListeners_.emplace_front(wakeupCallback);
-        return wakeupListeners_.begin();
-    }
+    WakeupListenerSubscription subscribeForWakeupEvents(WakeupCallback wakeupCallback);
 
     /**
      * \brief Unsubscribes your listeners for DispatchSources.
      */
-    inline void unsubscribeForDispatchSources(DispatchSourceListenerSubscription subscription) {
-        dispatchSourceListeners_.erase(subscription);
-    }
+    void unsubscribeForDispatchSources(DispatchSourceListenerSubscription subscription);
 
     /**
      * \brief Unsubscribes your listeners for Watches.
      */
-    inline void unsubscribeForWatches(WatchListenerSubscription subscription) {
-        watchListeners_.erase(subscription);
-    }
+    void unsubscribeForWatches(WatchListenerSubscription subscription);
 
     /**
      * \brief Unsubscribes your listeners for Timeouts.
      */
-    inline void unsubscribeForTimeouts(TimeoutSourceListenerSubscription subscription) {
-        timeoutSourceListeners_.erase(subscription);
-    }
+    void unsubscribeForTimeouts(TimeoutSourceListenerSubscription subscription);
 
     /**
      * \brief Unsubscribes your listeners for Wakeup-Events.
      */
-    inline void unsubscribeForWakeupEvents(WakeupListenerSubscription subscription) {
-        wakeupListeners_.erase(subscription);
-    }
+    void unsubscribeForWakeupEvents(WakeupListenerSubscription subscription);
 
     /**
      * \brief Notifies all listeners about a new DispatchSource.
      */
-    inline void registerDispatchSource(DispatchSource* dispatchSource, const DispatchPriority dispatchPriority = DispatchPriority::DEFAULT) {
-        for(auto listener = dispatchSourceListeners_.begin(); listener != dispatchSourceListeners_.end(); ++listener) {
-            listener->first(dispatchSource, dispatchPriority);
-        }
-    }
+    void registerDispatchSource(DispatchSource* dispatchSource, const DispatchPriority dispatchPriority = DispatchPriority::DEFAULT);
 
     /**
      * \brief Notifies all listeners about the removal of a DispatchSource.
      */
-    inline void deregisterDispatchSource(DispatchSource* dispatchSource) {
-        for(auto listener = dispatchSourceListeners_.begin(); listener != dispatchSourceListeners_.end(); ++listener) {
-            listener->second(dispatchSource);
-        }
-    }
+    void deregisterDispatchSource(DispatchSource* dispatchSource);
 
     /**
      * \brief Notifies all listeners about a new Watch.
      */
-    inline void registerWatch(Watch* watch, const DispatchPriority dispatchPriority = DispatchPriority::DEFAULT) {
-        for(auto listener = watchListeners_.begin(); listener != watchListeners_.end(); ++listener) {
-            listener->first(watch, dispatchPriority);
-        }
-    }
+    void registerWatch(Watch* watch, const DispatchPriority dispatchPriority = DispatchPriority::DEFAULT);
 
     /**
      * \brief Notifies all listeners about the removal of a Watch.
      */
-    inline void deregisterWatch(Watch* watch) {
-        for(auto listener = watchListeners_.begin(); listener != watchListeners_.end(); ++listener) {
-            listener->second(watch);
-        }
-    }
+    void deregisterWatch(Watch* watch);
 
     /**
      * \brief Notifies all listeners about a new Timeout.
      */
-    inline void registerTimeoutSource(Timeout* timeoutEvent, const DispatchPriority dispatchPriority = DispatchPriority::DEFAULT) {
-        for(auto listener = timeoutSourceListeners_.begin(); listener != timeoutSourceListeners_.end(); ++listener) {
-            listener->first(timeoutEvent, dispatchPriority);
-        }
-    }
+    void registerTimeoutSource(Timeout* timeoutEvent, const DispatchPriority dispatchPriority = DispatchPriority::DEFAULT);
 
     /**
      * \brief Notifies all listeners about the removal of a Timeout.
      */
-    inline void deregisterTimeoutSource(Timeout* timeoutEvent) {
-        for(auto listener = timeoutSourceListeners_.begin(); listener != timeoutSourceListeners_.end(); ++listener) {
-            listener->second(timeoutEvent);
-        }
-    }
+    void deregisterTimeoutSource(Timeout* timeoutEvent);
 
     /**
      * \brief Notifies all listeners about a wakeup event that just happened.
      */
-    inline void wakeup() {
-        for(auto listener = wakeupListeners_.begin(); listener != wakeupListeners_.end(); ++listener) {
-            (*listener)();
-        }
-    }
+    void wakeup();
 
     /**
      * \brief Will return true if at least one subscribe for DispatchSources or Watches has been called.
@@ -332,9 +278,7 @@ class MainLoopContext {
      * This function will be used to prevent creation of a factory if a mainloop context is given, but
      * no listeners have been registered. This is done in order to ensure correct use of the mainloop context.
      */
-    inline bool isInitialized() {
-        return dispatchSourceListeners_.size() > 0 || watchListeners_.size() > 0;
-    }
+    bool isInitialized();
 
  private:
     DispatchSourceListenerList dispatchSourceListeners_;
index 9b3a919..01b9d47 100644 (file)
@@ -31,7 +31,7 @@ static const char COMMONAPI_LIB_PREFIX[] = "libCommonAPI-";
 static const char MIDDLEWARE_INFO_SYMBOL_NAME[] = "middlewareInfo";
 
 #ifndef WIN32
-inline bool Runtime::tryLoadLibrary(const std::string& libraryPath,
+bool Runtime::tryLoadLibrary(const std::string& libraryPath,
                                     void** sharedLibraryHandle,
                                     MiddlewareInfo** foundMiddlewareInfo) {
 
index a1b02de..78daee3 100644 (file)
@@ -218,8 +218,8 @@ public:
      *
      * @return Index of contained type
      */
-    inline uint8_t getValueType() const {
-       return valueType_;
+    uint8_t getValueType() const {
+        return valueType_;
     }
 
 private:
index d6c4f95..eb2aaf8 100644 (file)
@@ -105,7 +105,7 @@ struct SelectiveBroadcastSubscriptionResult {
 template<typename _EnumType>
 class EnumHasher {
 public:
-    inline size_t operator()(const _EnumType& testEnum) const {
+    size_t operator()(const _EnumType& testEnum) const {
         return static_cast<int32_t>(testEnum);
     }
 
diff --git a/src/CommonAPI/utils.cpp b/src/CommonAPI/utils.cpp
new file mode 100644 (file)
index 0000000..303c32a
--- /dev/null
@@ -0,0 +1,181 @@
+/* Copyright (C) 2013 BMW Group
+ * Author: Manfred Bathelt (manfred.bathelt@bmw.de)
+ * Author: Juergen Gehring (juergen.gehring@bmw.de)
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "utils.h"
+
+namespace CommonAPI {
+std::string getCurrentBinaryFileFQN() {
+    #ifdef WIN32
+        TCHAR result[MAX_PATH];
+        std::basic_string<TCHAR> resultString(result, GetModuleFileName(NULL, result, MAX_PATH));
+        return std::string(resultString.begin(), resultString.end());
+    #else
+        char fqnOfBinary[FILENAME_MAX];
+        char pathToProcessImage[FILENAME_MAX];
+
+        sprintf(pathToProcessImage, "/proc/%d/exe", getpid());
+        const ssize_t lengthOfFqn = readlink(pathToProcessImage, fqnOfBinary, sizeof(fqnOfBinary) - 1);
+
+        if (lengthOfFqn != -1) {
+            fqnOfBinary[lengthOfFqn] = '\0';
+            return std::string(std::move(fqnOfBinary));
+        }
+        else {
+            return std::string("");
+        }
+    #endif
+    }
+
+std::vector<std::string>& split(const std::string& s, char delim, std::vector<std::string>& elems) {
+    std::istringstream ss(s);
+    std::string item;
+    while (std::getline(ss, item, delim)) {
+        elems.push_back(item);
+    }
+    return elems;
+}
+
+std::vector<std::string> split(const std::string& s, char delim) {
+    std::vector<std::string> elems;
+    return split(s, delim, elems);
+}
+
+void trim(std::string& toTrim) {
+    toTrim.erase(
+                    toTrim.begin(),
+                    std::find_if(toTrim.begin(),
+                                 toTrim.end(),
+                                 std::not1(std::ptr_fun(isspace)))
+                                                    );
+    toTrim.erase(
+                    std::find_if(toTrim.rbegin(),
+                                 toTrim.rend(),
+                                 std::not1(std::ptr_fun(isspace))).base(),
+                                 toTrim.end()
+                    );
+}
+
+bool notIsdigit(char c) {
+    return !std::isdigit(c, std::locale());
+}
+
+bool containsOnlyDigits(const std::string& toCheck) {
+    auto firstNonDigitIt = std::find_if(
+                    toCheck.begin(),
+                    toCheck.end(),
+                    notIsdigit);
+
+    return firstNonDigitIt == toCheck.end();
+}
+
+bool notIsalnum(char c) {
+    return !std::isalnum(c, std::locale());
+}
+
+bool containsOnlyAlphanumericCharacters(const std::string& toCheck) {
+    auto firstNonAlphanumericCharacterIt = std::find_if(
+                    toCheck.begin(),
+                    toCheck.end(),
+                    notIsalnum);
+
+    return firstNonAlphanumericCharacterIt == toCheck.end();
+}
+
+bool isValidDomainName(const std::string& domainName) {
+    return containsOnlyAlphanumericCharacters(domainName);
+}
+
+bool isValidServiceName(const std::string& serviceName) {
+    bool isValid = serviceName[0] != '.' && serviceName[serviceName.size() - 1] != '.';
+
+    if (isValid) {
+        std::vector<std::string> splittedServiceName = split(serviceName, '.');
+
+        for (auto serviceNameElementIt = splittedServiceName.begin();
+                        serviceNameElementIt != splittedServiceName.end() && isValid;
+                        ++serviceNameElementIt) {
+            isValid &= containsOnlyAlphanumericCharacters(*serviceNameElementIt);
+        }
+    }
+
+    return isValid;
+}
+
+bool isValidInstanceId(const std::string& instanceId) {
+    //Validation rules for ServiceName and InstanceID are equivalent
+    return isValidServiceName(instanceId);
+}
+
+bool isValidCommonApiAddress(const std::string& commonApiAddress) {
+    std::vector<std::string> splittedAddress = split(commonApiAddress, ':');
+    if (splittedAddress.size() != 3) {
+        return false;
+    }
+    return isValidDomainName(splittedAddress[0]) && isValidServiceName(splittedAddress[1]) && isValidInstanceId(splittedAddress[2]);
+}
+
+#ifndef WIN32
+bool loadGenericLibrary(const std::string& wellKnownMiddlewareName, const std::string& libraryName, const std::string& path, bool checkStandardNamePattern) {
+    std::string fqnOfLibrary = path + libraryName;
+    struct stat filestat;
+    if (stat(fqnOfLibrary.c_str(), &filestat)) {
+        return false;
+    }
+    if (S_ISDIR(filestat.st_mode)) {
+        return false;
+    }
+
+    if (checkStandardNamePattern) {
+        const std::string generatedLibPrefix = "lib" + wellKnownMiddlewareName + "Gen-";
+        if (strncmp(generatedLibPrefix.c_str(), libraryName.c_str(), generatedLibPrefix.length()) != 0) {
+            return false;
+        }
+
+        const char* fileNamePtr = libraryName.c_str();
+        while ((fileNamePtr = strchr(fileNamePtr + 1, '.'))) {
+            if (strncmp(".so\0", fileNamePtr, 4) == 0 || strncmp(".so.", fileNamePtr, 4) == 0) {
+                break;
+            }
+        }
+
+        if (!fileNamePtr) {
+            return false;
+        }
+    }
+
+    dlopen(fqnOfLibrary.c_str(), RTLD_NOW | RTLD_GLOBAL);
+    return true;
+}
+
+bool loadGenericLibrary(const std::string& wellKnownMiddlewareName,
+                               const std::string& fqnOfLibrary,
+                               bool checkStandardNamePattern) {
+    uint32_t position = fqnOfLibrary.find_last_of("/\\");
+    std::string path = fqnOfLibrary.substr(0, position + 1);
+    std::string file = fqnOfLibrary.substr(position + 1);
+    return loadGenericLibrary(wellKnownMiddlewareName, file, path, checkStandardNamePattern);
+}
+
+void findAndLoadGenericLibraries(const std::string& requestedMiddlewareName, const std::string& singleSearchPath) {
+    DIR *directory = opendir(singleSearchPath.c_str());
+
+    if (directory != NULL) {
+        struct dirent* entry;
+
+        while ((entry = readdir(directory))) {
+            loadGenericLibrary(requestedMiddlewareName, entry->d_name, singleSearchPath, true);
+        }
+    }
+}
+
+void findAndLoadGenericLibraries(const std::string& requestedMiddlewareName, const std::vector<std::string>& searchPaths) {
+    for (const std::string& singleSearchPath : searchPaths) {
+        findAndLoadGenericLibraries(requestedMiddlewareName, singleSearchPath.c_str());
+    }
+}
+#endif
+}//namespace CommonAPI
index 1224de1..c0e78eb 100644 (file)
@@ -48,27 +48,7 @@ namespace CommonAPI {
  *
  * @return The name of the currently executing binary.
  */
-inline std::string getCurrentBinaryFileFQN() {
-#ifdef WIN32
-    TCHAR result[MAX_PATH];
-    std::basic_string<TCHAR> resultString(result, GetModuleFileName(NULL, result, MAX_PATH));
-    return std::string(resultString.begin(), resultString.end());
-#else
-    char fqnOfBinary[FILENAME_MAX];
-    char pathToProcessImage[FILENAME_MAX];
-
-    sprintf(pathToProcessImage, "/proc/%d/exe", getpid());
-    const ssize_t lengthOfFqn = readlink(pathToProcessImage, fqnOfBinary, sizeof(fqnOfBinary) - 1);
-
-    if (lengthOfFqn != -1) {
-        fqnOfBinary[lengthOfFqn] = '\0';
-        return std::string(std::move(fqnOfBinary));
-    }
-    else {
-        return std::string("");
-    }
-#endif
-}
+std::string getCurrentBinaryFileFQN();
 
 /**
  * \brief Splits a std::string according to the given delim-char.
@@ -82,14 +62,7 @@ inline std::string getCurrentBinaryFileFQN() {
  *
  * @return A reference to the vector you passed in (elems)
  */
-inline std::vector<std::string>& split(const std::string& s, char delim, std::vector<std::string>& elems) {
-    std::istringstream ss(s);
-    std::string item;
-    while (std::getline(ss, item, delim)) {
-        elems.push_back(item);
-    }
-    return elems;
-}
+std::vector<std::string>& split(const std::string& s, char delim, std::vector<std::string>& elems);
 
 /**
  * \brief Splits a std::string according to the given delim-char.
@@ -102,10 +75,7 @@ inline std::vector<std::string>& split(const std::string& s, char delim, std::ve
  *
  * @return A vector containing the splitted string elements.
  */
-inline std::vector<std::string> split(const std::string& s, char delim) {
-    std::vector<std::string> elems;
-    return split(s, delim, elems);
-}
+std::vector<std::string> split(const std::string& s, char delim);
 
 inline bool isspace(char c) {
     return std::isspace(c, std::locale());
@@ -116,24 +86,9 @@ inline bool isspace(char c) {
  *
  * @param toTrim: The string that is to be trimmed.
  */
-inline void trim(std::string& toTrim) {
-    toTrim.erase(
-                    toTrim.begin(),
-                    std::find_if(toTrim.begin(),
-                                 toTrim.end(),
-                                 std::not1(std::ptr_fun(isspace)))
-                                                    );
-    toTrim.erase(
-                    std::find_if(toTrim.rbegin(),
-                                 toTrim.rend(),
-                                 std::not1(std::ptr_fun(isspace))).base(),
-                                 toTrim.end()
-                    );
-}
+void trim(std::string& toTrim);
 
-inline bool notIsdigit(char c) {
-    return !std::isdigit(c, std::locale());
-}
+bool notIsdigit(char c);
 
 /**
  * \brief Checks whether the given string contains nothing but digits.
@@ -142,18 +97,9 @@ inline bool notIsdigit(char c) {
  *
  * @return true if toCheck contains nothing but digits, false otherwise.
  */
-inline bool containsOnlyDigits(const std::string& toCheck) {
-    auto firstNonDigitIt = std::find_if(
-                    toCheck.begin(),
-                    toCheck.end(),
-                    notIsdigit);
-
-    return firstNonDigitIt == toCheck.end();
-}
+bool containsOnlyDigits(const std::string& toCheck);
 
-inline bool notIsalnum(char c) {
-    return !std::isalnum(c, std::locale());
-}
+bool notIsalnum(char c);
 
 /**
  * \brief Checks whether the given string contains nothing but alphanumeric characters.
@@ -162,14 +108,7 @@ inline bool notIsalnum(char c) {
  *
  * @return true if toCheck contains nothing but alphanumeric characters, false otherwise.
  */
-inline bool containsOnlyAlphanumericCharacters(const std::string& toCheck) {
-    auto firstNonAlphanumericCharacterIt = std::find_if(
-                    toCheck.begin(),
-                    toCheck.end(),
-                    notIsalnum);
-
-    return firstNonAlphanumericCharacterIt == toCheck.end();
-}
+bool containsOnlyAlphanumericCharacters(const std::string& toCheck);
 
 /**
  * \brief Checks whether the given std::string is a valid CommonAPI domain name.
@@ -178,9 +117,7 @@ inline bool containsOnlyAlphanumericCharacters(const std::string& toCheck) {
  *
  * @return true if domainName is a valid CommonAPI domainName, false otherwise.
  */
-inline bool isValidDomainName(const std::string& domainName) {
-    return containsOnlyAlphanumericCharacters(domainName);
-}
+bool isValidDomainName(const std::string& domainName);
 
 /**
  * \brief Checks whether the given std::string is a valid CommonAPI service name.
@@ -189,21 +126,7 @@ inline bool isValidDomainName(const std::string& domainName) {
  *
  * @return true if serviceName is a valid CommonAPI serviceName, false otherwise.
  */
-inline bool isValidServiceName(const std::string& serviceName) {
-    bool isValid = serviceName[0] != '.' && serviceName[serviceName.size() - 1] != '.';
-
-    if (isValid) {
-        std::vector<std::string> splittedServiceName = split(serviceName, '.');
-
-        for (auto serviceNameElementIt = splittedServiceName.begin();
-                        serviceNameElementIt != splittedServiceName.end() && isValid;
-                        ++serviceNameElementIt) {
-            isValid &= containsOnlyAlphanumericCharacters(*serviceNameElementIt);
-        }
-    }
-
-    return isValid;
-}
+bool isValidServiceName(const std::string& serviceName);
 
 /**
  * \brief Checks whether the given std::string is a valid CommonAPI instance ID.
@@ -212,10 +135,7 @@ inline bool isValidServiceName(const std::string& serviceName) {
  *
  * @return true if instanceId is a valid CommonAPI instance ID, false otherwise.
  */
-inline bool isValidInstanceId(const std::string& instanceId) {
-    //Validation rules for ServiceName and InstanceID are equivalent
-    return isValidServiceName(instanceId);
-}
+bool isValidInstanceId(const std::string& instanceId);
 
 /**
  * \brief Checks whether the given std::string is a valid CommonAPI address.
@@ -224,13 +144,7 @@ inline bool isValidInstanceId(const std::string& instanceId) {
  *
  * @return true if commonApiAddress is a valid CommonAPI address, false otherwise.
  */
-inline bool isValidCommonApiAddress(const std::string& commonApiAddress) {
-    std::vector<std::string> splittedAddress = split(commonApiAddress, ':');
-    if (splittedAddress.size() != 3) {
-        return false;
-    }
-    return isValidDomainName(splittedAddress[0]) && isValidServiceName(splittedAddress[1]) && isValidInstanceId(splittedAddress[2]);
-}
+bool isValidCommonApiAddress(const std::string& commonApiAddress);
 
 #ifndef WIN32
 /**
@@ -255,37 +169,7 @@ inline bool isValidCommonApiAddress(const std::string& commonApiAddress) {
  *       only by specific middlewares. This name however will only be taken into consideration during name checking
  *       if the checkStandardNamePattern flag is set to true.
  */
-inline bool loadGenericLibrary(const std::string& wellKnownMiddlewareName, const std::string& libraryName, const std::string& path, bool checkStandardNamePattern = true) {
-    std::string fqnOfLibrary = path + libraryName;
-    struct stat filestat;
-    if (stat(fqnOfLibrary.c_str(), &filestat)) {
-        return false;
-    }
-    if (S_ISDIR(filestat.st_mode)) {
-        return false;
-    }
-
-    if (checkStandardNamePattern) {
-        const std::string generatedLibPrefix = "lib" + wellKnownMiddlewareName + "Gen-";
-        if (strncmp(generatedLibPrefix.c_str(), libraryName.c_str(), generatedLibPrefix.length()) != 0) {
-            return false;
-        }
-
-        const char* fileNamePtr = libraryName.c_str();
-        while ((fileNamePtr = strchr(fileNamePtr + 1, '.'))) {
-            if (strncmp(".so\0", fileNamePtr, 4) == 0 || strncmp(".so.", fileNamePtr, 4) == 0) {
-                break;
-            }
-        }
-
-        if (!fileNamePtr) {
-            return false;
-        }
-    }
-
-    dlopen(fqnOfLibrary.c_str(), RTLD_NOW | RTLD_GLOBAL);
-    return true;
-}
+bool loadGenericLibrary(const std::string& wellKnownMiddlewareName, const std::string& libraryName, const std::string& path, bool checkStandardNamePattern = true);
 
 /**
  * \brief Loads a specific generic library at runtime.
@@ -307,15 +191,9 @@ inline bool loadGenericLibrary(const std::string& wellKnownMiddlewareName, const
  *       only by specific middlewares. This name however will only be taken into consideration during name checking
  *       if the checkStandardNamePattern flag is set to true.
  */
-inline bool loadGenericLibrary(const std::string& wellKnownMiddlewareName,
+bool loadGenericLibrary(const std::string& wellKnownMiddlewareName,
                                const std::string& fqnOfLibrary,
-                               bool checkStandardNamePattern = true) {
-    uint32_t position = fqnOfLibrary.find_last_of("/\\");
-    std::string path = fqnOfLibrary.substr(0, position + 1);
-    std::string file = fqnOfLibrary.substr(position + 1);
-    return loadGenericLibrary(wellKnownMiddlewareName, file, path, checkStandardNamePattern);
-}
-
+                               bool checkStandardNamePattern = true);
 
 /**
  * \brief Searches the given path for additional generic CommonAPI libraries and loads them.
@@ -329,17 +207,7 @@ inline bool loadGenericLibrary(const std::string& wellKnownMiddlewareName,
  *                                 be used to perform the name check.
  * @param singleSearchPath: The directory that is to be searched for libraries.
  */
-inline void findAndLoadGenericLibraries(const std::string& requestedMiddlewareName, const std::string& singleSearchPath) {
-    DIR *directory = opendir(singleSearchPath.c_str());
-
-    if (directory != NULL) {
-        struct dirent* entry;
-
-        while ((entry = readdir(directory))) {
-            loadGenericLibrary(requestedMiddlewareName, entry->d_name, singleSearchPath, true);
-        }
-    }
-}
+void findAndLoadGenericLibraries(const std::string& requestedMiddlewareName, const std::string& singleSearchPath);
 
 /**
  * \brief Searches the given paths for additional generic CommonAPI libraries and loads them.
@@ -353,11 +221,7 @@ inline void findAndLoadGenericLibraries(const std::string& requestedMiddlewareNa
  *                                 be used to perform the name check.
  * @param searchPaths: The directories that are to be searched for libraries.
  */
-inline void findAndLoadGenericLibraries(const std::string& requestedMiddlewareName, const std::vector<std::string>& searchPaths) {
-    for (const std::string& singleSearchPath : searchPaths) {
-        findAndLoadGenericLibraries(requestedMiddlewareName, singleSearchPath.c_str());
-    }
-}
+void findAndLoadGenericLibraries(const std::string& requestedMiddlewareName, const std::vector<std::string>& searchPaths);
 #endif
 
 } //namespace CommonAPI