diff options
author | GENIVI Audio Manager Maintainer <genivi-maint-audiomanager@smtp1.genivi.org> | 2018-07-12 17:11:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-12 17:11:02 +0200 |
commit | 4f261b37238d310cc74ca5b1d9ca244ec3c5b70e (patch) | |
tree | d0e8c492a9da884aa57f6464dc515605eba705e0 /AudioManagerUtilities/include/CAmCommonAPIWrapper.h | |
parent | f93c2b7d4840b181a6375da2bde0a3679278a6b6 (diff) | |
parent | 95c696f818b6840bcbefe6d376ff01fa02dfd772 (diff) | |
download | audiomanager-4f261b37238d310cc74ca5b1d9ca244ec3c5b70e.tar.gz |
Merge pull request #35 from JensLorenz/issue_24_clean_up_whitespace
Issue #24 clean up whitespace
Diffstat (limited to 'AudioManagerUtilities/include/CAmCommonAPIWrapper.h')
-rw-r--r-- | AudioManagerUtilities/include/CAmCommonAPIWrapper.h | 421 |
1 files changed, 212 insertions, 209 deletions
diff --git a/AudioManagerUtilities/include/CAmCommonAPIWrapper.h b/AudioManagerUtilities/include/CAmCommonAPIWrapper.h index a83b5b3..a384f33 100644 --- a/AudioManagerUtilities/include/CAmCommonAPIWrapper.h +++ b/AudioManagerUtilities/include/CAmCommonAPIWrapper.h @@ -15,7 +15,6 @@ * For further information see http://www.genivi.org/. */ - #ifndef COMMONAPIWRAPPER_H_ #define COMMONAPIWRAPPER_H_ @@ -27,9 +26,9 @@ #include <cassert> #include <CommonAPI/CommonAPI.hpp> #ifndef COMMONAPI_INTERNAL_COMPILATION -#define COMMONAPI_INTERNAL_COMPILATION -#include <CommonAPI/MainLoopContext.hpp> -#undef COMMONAPI_INTERNAL_COMPILATION +# define COMMONAPI_INTERNAL_COMPILATION +# include <CommonAPI/MainLoopContext.hpp> +# undef COMMONAPI_INTERNAL_COMPILATION #endif #include <CommonAPI/Utils.hpp> #include "audiomanagerconfig.h" @@ -48,247 +47,251 @@ class CAmSocketHandler; class CAmCommonAPIWrapper { - void commonPrepareCallback(const sh_pollHandle_t handle, void* userData); - TAmShPollPrepare<CAmCommonAPIWrapper> pCommonPrepareCallback; + void commonPrepareCallback(const sh_pollHandle_t handle, void *userData); + + TAmShPollPrepare<CAmCommonAPIWrapper> pCommonPrepareCallback; + + bool commonDispatchCallback(const sh_pollHandle_t handle, void *userData); - bool commonDispatchCallback(const sh_pollHandle_t handle, void* userData); TAmShPollDispatch<CAmCommonAPIWrapper> pCommonDispatchCallback; - void commonFireCallback(const pollfd pollfd, const sh_pollHandle_t, void*); + void commonFireCallback(const pollfd pollfd, const sh_pollHandle_t, void *); + TAmShPollFired<CAmCommonAPIWrapper> pCommonFireCallback; - bool commonCheckCallback(const sh_pollHandle_t handle, void*); + bool commonCheckCallback(const sh_pollHandle_t handle, void *); + TAmShPollCheck<CAmCommonAPIWrapper> pCommonCheckCallback; - void commonTimerCallback(sh_timerHandle_t handle, void* userData); + void commonTimerCallback(sh_timerHandle_t handle, void *userData); + TAmShTimerCallBack<CAmCommonAPIWrapper> pCommonTimerCallback; - struct timerHandles + struct timerHandles { sh_timerHandle_t handle; - CommonAPI::Timeout* timeout; + CommonAPI::Timeout *timeout; }; - CAmSocketHandler *mpSocketHandler; //!< pointer to the sockethandler + CAmSocketHandler *mpSocketHandler; //!< pointer to the sockethandler - std::shared_ptr<CommonAPI::Runtime> mRuntime; - std::shared_ptr<CommonAPI::MainLoopContext> mContext; + std::shared_ptr<CommonAPI::Runtime> mRuntime; + std::shared_ptr<CommonAPI::MainLoopContext> mContext; CommonAPI::DispatchSourceListenerSubscription mDispatchSourceListenerSubscription; - CommonAPI::WatchListenerSubscription mWatchListenerSubscription; - CommonAPI::TimeoutSourceListenerSubscription mTimeoutSourceListenerSubscription; - CommonAPI::WakeupListenerSubscription mWakeupListenerSubscription; - std::multimap<CommonAPI::DispatchPriority, CommonAPI::DispatchSource*> mRegisteredDispatchSources; - std::map<int,CommonAPI::Watch*> mMapWatches; - CommonAPI::Watch* mWatchToCheck; - std::list<CommonAPI::DispatchSource*> mSourcesToDispatch; - std::vector<timerHandles> mpListTimerhandles; - - void registerDispatchSource(CommonAPI::DispatchSource* dispatchSource, const CommonAPI::DispatchPriority dispatchPriority); - void deregisterDispatchSource(CommonAPI::DispatchSource* dispatchSource); - void registerWatch(CommonAPI::Watch* watch, const CommonAPI::DispatchPriority dispatchPriority); - void deregisterWatch(CommonAPI::Watch* watch); - void registerTimeout(CommonAPI::Timeout* timeout, const CommonAPI::DispatchPriority dispatchPriority); - void deregisterTimeout(CommonAPI::Timeout* timeout); - void wakeup(); + CommonAPI::WatchListenerSubscription mWatchListenerSubscription; + CommonAPI::TimeoutSourceListenerSubscription mTimeoutSourceListenerSubscription; + CommonAPI::WakeupListenerSubscription mWakeupListenerSubscription; + std::multimap<CommonAPI::DispatchPriority, CommonAPI::DispatchSource *> mRegisteredDispatchSources; + std::map<int, CommonAPI::Watch *> mMapWatches; + CommonAPI::Watch *mWatchToCheck; + std::list<CommonAPI::DispatchSource *> mSourcesToDispatch; + std::vector<timerHandles> mpListTimerhandles; + + void registerDispatchSource(CommonAPI::DispatchSource *dispatchSource, const CommonAPI::DispatchPriority dispatchPriority); + void deregisterDispatchSource(CommonAPI::DispatchSource *dispatchSource); + void registerWatch(CommonAPI::Watch *watch, const CommonAPI::DispatchPriority dispatchPriority); + void deregisterWatch(CommonAPI::Watch *watch); + void registerTimeout(CommonAPI::Timeout *timeout, const CommonAPI::DispatchPriority dispatchPriority); + void deregisterTimeout(CommonAPI::Timeout *timeout); + void wakeup(); protected: - CAmCommonAPIWrapper(CAmSocketHandler* socketHandler, const std::string & applicationName = "") ; + CAmCommonAPIWrapper(CAmSocketHandler *socketHandler, const std::string &applicationName = ""); public: virtual ~CAmCommonAPIWrapper(); - /** - * \brief Returns an already instantiated object. - * - * This method should be called after the instantiateOnce(...) has been called with non null socket handler parameter. - * - * @return The common-api wrapper object. - */ - static CAmCommonAPIWrapper* getInstance(); - - /** - * \brief Deletes the instanciated object - */ - static void deleteInstance(); - - /** - * \brief Creates a singleton instance attached to the provided socket handler object. - * - * This method should be called only once because it instantiates a single object. - * Otherwise it will throw an exception. - * The first call of this method with non null parameter loads the common-api and attaches it to the main loop. - * - * @param socketHandler: A pointer to socket handler or NULL - * - * @return The common-api wrapper object. - */ - static CAmCommonAPIWrapper* instantiateOnce(CAmSocketHandler* socketHandler, const std::string & applicationName = ""); - - - /** - * \brief Getter for the socket handler. - * - * @return Pointer to the socket handler. - */ - CAmSocketHandler *getSocketHandler() const { return mpSocketHandler; } - - /** - * \brief Deprecated method. This class is used only in single connection applications and no connectionId is needed. Instead you should use bool registerService(const std::shared_ptr<TStubImp> & shStub, const std::string & domain, const std::string & instance). - * - * - * Example: std::shared_ptr<ConcreteStubClass> aStub; - * registerService( aStub, "local", "com.your_company.instance_name", "service-name"); - * - * @param shStub: Shared pointer to a stub instance - * @param domain: A string with the domain name, usually "local" - * @param instance: Common-api instance string as example "com.your_company.instance_name" - * @param connectionId: A string connection id, which is used by CommonAPI to group applications - * - */ - template <class TStubImp> bool __attribute__((deprecated)) registerService(const std::shared_ptr<TStubImp> & shStub, const std::string & domain, const std::string & instance, const CommonAPI::ConnectionId_t __attribute__((__unused__)) & /*connectionId*/) - { - return mRuntime->registerService(domain, instance, shStub, mContext); - } - - /** - * \brief Register stub objects. - * - * Example: std::shared_ptr<ConcreteStubClass> aStub; - * registerService( aStub, "local", "com.your_company.instance_name"); - * - * @param shStub: Shared pointer to a stub instance - * @param domain: A string with the domain name, usually "local" - * @param instance: Common-api instance string as example "com.your_company.instance_name" - * - */ - template <class TStubImp> bool registerService(const std::shared_ptr<TStubImp> & shStub, const std::string & domain, const std::string & instance) - { - return mRuntime->registerService(domain, instance, shStub, mContext); - } - - /** - * \brief Unregister stub objects. - * - * @param domain: A string with the domain name, usually "local" - * @param interface: Common-api interface string as example "com.your_company.interface_name" - * @param instance: Common-api instance string as example "com.your_company.instance_name" - * - */ - bool unregisterService(const std::string &domain, const std::string &interface, const std::string &instance) - { - return mRuntime->unregisterService(domain, interface, instance); - } - - /** - * \brief Deprecated method. Instead you should use bool registerService(const std::shared_ptr<TStubImp> & shStub, const std::string & domain, const std::string & instance). - * - * Register stub objects. - * - * Example: std::shared_ptr<ConcreteStubClass> aStub; - * registerService( aStub, "local:com.your_company.interface_name:com.your_company.instance_name"); - * - * @param shStub: Shared pointer to a stub instance - * @param address: Complete common-api address as example "local:com.your_company.interface_name:com.your_company.instance_name" - * - */ - template <class TStubImp> bool __attribute__((deprecated)) registerStub(const std::shared_ptr<TStubImp> & shStub, const std::string & address) - { - std::vector<std::string> parts = CommonAPI::split(address, ':'); - assert(parts.size()==3); - - return registerService(shStub, parts[0], parts[2]); - } - - /** - * \brief Deprecated method. Instead you should use bool unregisterService(const std::string &domain, const std::string &interface, const std::string &instance). - * - * Unregister stub objects. - * - * @param address: Complete common-api address as example "local:com.your_company.interface_name:com.your_company.instance_name" - * - */ - bool __attribute__((deprecated)) unregisterStub(const std::string & address) - { - std::vector<std::string> parts = CommonAPI::split(address, ':'); - assert(parts.size()==3); - - return unregisterService(parts[0], parts[1], parts[2]); - } - - /** - * \brief Deprecated method. This class is used only in single connection applications and no connectionId is needed. Instead you should use buildProxy(const std::string &domain, const std::string &instance). - * - * Example: std::shared_ptr<AProxyClass<>> aProxy = buildProxy<AProxyClass>("local", "com.your_company.instance_name", "client-name"); - * - * @param domain: A string with the domain name, usually "local" - * @param instance: Common-api instance string as example "com.your_company.instance_name" - * @param connectionId: A string connection id, which is used by CommonAPI to group applications - * - * @return A proxy object. - */ - template<template<typename ...> class ProxyClass, typename ... AttributeExtensions> - std::shared_ptr<ProxyClass<AttributeExtensions...>> __attribute__((deprecated)) buildProxy(const std::string &domain, const std::string &instance, const CommonAPI::ConnectionId_t __attribute__((__unused__)) & /*connectionId*/) - { - return mRuntime->buildProxy<ProxyClass>(domain, instance, mContext); - } - - /** - * \brief Build proxy objects. - * - * Example: std::shared_ptr<AProxyClass<>> aProxy = buildProxy<AProxyClass>("local", "com.your_company.instance_name"); - * - * @param domain: A string with the domain name, usually "local" - * @param instance: Common-api instance string as example "com.your_company.instance_name" - * - * @return A proxy object. - */ - template<template<typename ...> class ProxyClass, typename ... AttributeExtensions> - std::shared_ptr<ProxyClass<AttributeExtensions...>> buildProxy(const std::string &domain, const std::string &instance) - { - return mRuntime->buildProxy<ProxyClass>(domain, instance, mContext); - } - - - /** - * \brief Deprecated method. Instead you should use buildProxy(const std::string &domain, const std::string &instance). - * - * Build proxy objects. - * Example: std::shared_ptr<AProxyClass<>> aProxy = buildProxy<AProxyClass>("local:com.your_company.interface_name:com.your_company.instance_name"); - * - * @param address: Complete common-api address as example "local:com.your_company.interface_name:com.your_company.instance_name" - * - * @return A proxy object. - */ - template<template<typename ...> class ProxyClass, typename ... AttributeExtensions> - std::shared_ptr<ProxyClass<AttributeExtensions...>> __attribute__((deprecated)) buildProxy(const std::string & address) - { - std::vector<std::string> parts=CommonAPI::split(address, ':'); - assert(parts.size()==3); - - return buildProxy<ProxyClass>(parts[0], parts[2]); - } + /** + * \brief Returns an already instantiated object. + * + * This method should be called after the instantiateOnce(...) has been called with non null socket handler parameter. + * + * @return The common-api wrapper object. + */ + static CAmCommonAPIWrapper *getInstance(); + + /** + * \brief Deletes the instanciated object + */ + static void deleteInstance(); + + /** + * \brief Creates a singleton instance attached to the provided socket handler object. + * + * This method should be called only once because it instantiates a single object. + * Otherwise it will throw an exception. + * The first call of this method with non null parameter loads the common-api and attaches it to the main loop. + * + * @param socketHandler: A pointer to socket handler or NULL + * + * @return The common-api wrapper object. + */ + static CAmCommonAPIWrapper *instantiateOnce(CAmSocketHandler *socketHandler, const std::string &applicationName = ""); + + /** + * \brief Getter for the socket handler. + * + * @return Pointer to the socket handler. + */ + CAmSocketHandler *getSocketHandler() const { return mpSocketHandler; } + + /** + * \brief Deprecated method. This class is used only in single connection applications and no connectionId is needed. Instead you should use bool registerService(const std::shared_ptr<TStubImp> & shStub, const std::string & domain, const std::string & instance). + * + * + * Example: std::shared_ptr<ConcreteStubClass> aStub; + * registerService( aStub, "local", "com.your_company.instance_name", "service-name"); + * + * @param shStub: Shared pointer to a stub instance + * @param domain: A string with the domain name, usually "local" + * @param instance: Common-api instance string as example "com.your_company.instance_name" + * @param connectionId: A string connection id, which is used by CommonAPI to group applications + * + */ + template <class TStubImp> + bool __attribute__((deprecated)) registerService(const std::shared_ptr<TStubImp> &shStub, const std::string &domain, const std::string &instance, const CommonAPI::ConnectionId_t __attribute__((__unused__)) & /*connectionId*/) + { + return mRuntime->registerService(domain, instance, shStub, mContext); + } + + /** + * \brief Register stub objects. + * + * Example: std::shared_ptr<ConcreteStubClass> aStub; + * registerService( aStub, "local", "com.your_company.instance_name"); + * + * @param shStub: Shared pointer to a stub instance + * @param domain: A string with the domain name, usually "local" + * @param instance: Common-api instance string as example "com.your_company.instance_name" + * + */ + template <class TStubImp> + bool registerService(const std::shared_ptr<TStubImp> &shStub, const std::string &domain, const std::string &instance) + { + return mRuntime->registerService(domain, instance, shStub, mContext); + } + + /** + * \brief Unregister stub objects. + * + * @param domain: A string with the domain name, usually "local" + * @param interface: Common-api interface string as example "com.your_company.interface_name" + * @param instance: Common-api instance string as example "com.your_company.instance_name" + * + */ + bool unregisterService(const std::string &domain, const std::string &interface, const std::string &instance) + { + return mRuntime->unregisterService(domain, interface, instance); + } + + /** + * \brief Deprecated method. Instead you should use bool registerService(const std::shared_ptr<TStubImp> & shStub, const std::string & domain, const std::string & instance). + * + * Register stub objects. + * + * Example: std::shared_ptr<ConcreteStubClass> aStub; + * registerService( aStub, "local:com.your_company.interface_name:com.your_company.instance_name"); + * + * @param shStub: Shared pointer to a stub instance + * @param address: Complete common-api address as example "local:com.your_company.interface_name:com.your_company.instance_name" + * + */ + template <class TStubImp> + bool __attribute__((deprecated)) registerStub(const std::shared_ptr<TStubImp> &shStub, const std::string &address) + { + std::vector<std::string> parts = CommonAPI::split(address, ':'); + assert(parts.size() == 3); + + return registerService(shStub, parts[0], parts[2]); + } + + /** + * \brief Deprecated method. Instead you should use bool unregisterService(const std::string &domain, const std::string &interface, const std::string &instance). + * + * Unregister stub objects. + * + * @param address: Complete common-api address as example "local:com.your_company.interface_name:com.your_company.instance_name" + * + */ + bool __attribute__((deprecated)) unregisterStub(const std::string &address) + { + std::vector<std::string> parts = CommonAPI::split(address, ':'); + assert(parts.size() == 3); + + return unregisterService(parts[0], parts[1], parts[2]); + } + + /** + * \brief Deprecated method. This class is used only in single connection applications and no connectionId is needed. Instead you should use buildProxy(const std::string &domain, const std::string &instance). + * + * Example: std::shared_ptr<AProxyClass<>> aProxy = buildProxy<AProxyClass>("local", "com.your_company.instance_name", "client-name"); + * + * @param domain: A string with the domain name, usually "local" + * @param instance: Common-api instance string as example "com.your_company.instance_name" + * @param connectionId: A string connection id, which is used by CommonAPI to group applications + * + * @return A proxy object. + */ + template<template<typename...> class ProxyClass, typename... AttributeExtensions> + std::shared_ptr<ProxyClass<AttributeExtensions...> > __attribute__((deprecated)) buildProxy(const std::string &domain, const std::string &instance, const CommonAPI::ConnectionId_t __attribute__((__unused__)) & /*connectionId*/) + { + return mRuntime->buildProxy<ProxyClass>(domain, instance, mContext); + } + + /** + * \brief Build proxy objects. + * + * Example: std::shared_ptr<AProxyClass<>> aProxy = buildProxy<AProxyClass>("local", "com.your_company.instance_name"); + * + * @param domain: A string with the domain name, usually "local" + * @param instance: Common-api instance string as example "com.your_company.instance_name" + * + * @return A proxy object. + */ + template<template<typename...> class ProxyClass, typename... AttributeExtensions> + std::shared_ptr<ProxyClass<AttributeExtensions...> > buildProxy(const std::string &domain, const std::string &instance) + { + return mRuntime->buildProxy<ProxyClass>(domain, instance, mContext); + } + + /** + * \brief Deprecated method. Instead you should use buildProxy(const std::string &domain, const std::string &instance). + * + * Build proxy objects. + * Example: std::shared_ptr<AProxyClass<>> aProxy = buildProxy<AProxyClass>("local:com.your_company.interface_name:com.your_company.instance_name"); + * + * @param address: Complete common-api address as example "local:com.your_company.interface_name:com.your_company.instance_name" + * + * @return A proxy object. + */ + template<template<typename...> class ProxyClass, typename... AttributeExtensions> + std::shared_ptr<ProxyClass<AttributeExtensions...> > __attribute__((deprecated)) buildProxy(const std::string &address) + { + std::vector<std::string> parts = CommonAPI::split(address, ':'); + assert(parts.size() == 3); -}; + return buildProxy<ProxyClass>(parts[0], parts[2]); + } +}; -//Alias -extern CAmCommonAPIWrapper* (*getCAPI)(); +// Alias +extern CAmCommonAPIWrapper *(*getCAPI)(); #ifndef AMCAPI - #define AMCAPI getCAPI() +# define AMCAPI getCAPI() #endif #ifndef AM_CAPI - #define AM_CAPI getCAPI() +# define AM_CAPI getCAPI() #endif #ifndef CAPI - #define CAPI getCAPI() +# define CAPI getCAPI() #endif - } #endif /* COMMONAPIWRAPPER_H_ */ |