From 1d273417806ee5a6b1a8e92586f149f0f7877253 Mon Sep 17 00:00:00 2001 From: Jens Lorenz Date: Tue, 13 Mar 2018 13:37:37 +0100 Subject: Revert "Utility updates capi fixes" --- .../include/CAmCommonAPIWrapper.h | 246 ++++++++++----------- 1 file changed, 119 insertions(+), 127 deletions(-) (limited to 'AudioManagerUtilities/include/CAmCommonAPIWrapper.h') diff --git a/AudioManagerUtilities/include/CAmCommonAPIWrapper.h b/AudioManagerUtilities/include/CAmCommonAPIWrapper.h index 7d64a04..82328d6 100644 --- a/AudioManagerUtilities/include/CAmCommonAPIWrapper.h +++ b/AudioManagerUtilities/include/CAmCommonAPIWrapper.h @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -49,37 +48,29 @@ class CAmSocketHandler; class CAmCommonAPIWrapper { - void commonPrepareCallback ( const sh_pollHandle_t, void* ); + void commonPrepareCallback(const sh_pollHandle_t handle, void* userData); TAmShPollPrepare pCommonPrepareCallback; + bool commonDispatchCallback(const sh_pollHandle_t handle, void* userData); + TAmShPollDispatch pCommonDispatchCallback; + void commonFireCallback(const pollfd pollfd, const sh_pollHandle_t, void*); TAmShPollFired pCommonFireCallback; bool commonCheckCallback(const sh_pollHandle_t handle, void*); TAmShPollCheck pCommonCheckCallback; - - bool commonDispatchCallback(const sh_pollHandle_t handle, void* userData); - TAmShPollDispatch pCommonDispatchCallback; void commonTimerCallback(sh_timerHandle_t handle, void* userData); TAmShTimerCallBack pCommonTimerCallback; + struct timerHandles + { + sh_timerHandle_t handle; + CommonAPI::Timeout* timeout; + }; + CAmSocketHandler *mpSocketHandler; //!< pointer to the sockethandler - typedef std::vector ArrayDispatchSources; - typedef ArrayDispatchSources::iterator IteratorArrayDispatchSources; - typedef std::unordered_map MapWatches; - typedef MapWatches::iterator IteratorMapWatches; - typedef std::unordered_map> MapDispatchSources; - typedef MapDispatchSources::iterator IteratorDispatchSources; - typedef std::unordered_map MapTimeouts; - typedef MapTimeouts::iterator IteratorMapTimeouts; - - ArrayDispatchSources mRegisteredDispatchSources; - MapWatches mMapWatches; - MapDispatchSources mSourcesToDispatch; - MapTimeouts mListTimerhandles; - std::shared_ptr mRuntime; std::shared_ptr mContext; @@ -87,23 +78,22 @@ class CAmCommonAPIWrapper CommonAPI::WatchListenerSubscription mWatchListenerSubscription; CommonAPI::TimeoutSourceListenerSubscription mTimeoutSourceListenerSubscription; CommonAPI::WakeupListenerSubscription mWakeupListenerSubscription; - + std::multimap mRegisteredDispatchSources; + std::map mMapWatches; + CommonAPI::Watch* mWatchToCheck; + std::list mSourcesToDispatch; + std::vector mpListTimerhandles; void registerDispatchSource(CommonAPI::DispatchSource* dispatchSource, const CommonAPI::DispatchPriority dispatchPriority); void deregisterDispatchSource(CommonAPI::DispatchSource* dispatchSource); - void deregisterAllDispatchSource(); void registerWatch(CommonAPI::Watch* watch, const CommonAPI::DispatchPriority dispatchPriority); void deregisterWatch(CommonAPI::Watch* watch); - void deregisterAllWatches(); void registerTimeout(CommonAPI::Timeout* timeout, const CommonAPI::DispatchPriority dispatchPriority); void deregisterTimeout(CommonAPI::Timeout* timeout); - void deregisterAllTimeouts(); - - CommonAPI::Watch* watchWithHandle(const sh_pollHandle_t handle); - CommonAPI::Timeout* timeoutWithHandle(const sh_pollHandle_t handle); + void wakeup(); protected: - CAmCommonAPIWrapper(CAmSocketHandler* socketHandler, const std::string& applicationName = "") ; + CAmCommonAPIWrapper(CAmSocketHandler* socketHandler, const std::string & applicationName = "") ; public: @@ -143,25 +133,24 @@ public: * @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 & shStub, const std::string & domain, const std::string & instance). - * - * - * Example: std::shared_ptr 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 bool __attribute__((deprecated)) registerService(const std::shared_ptr & shStub, const std::string & domain, const std::string & instance, const CommonAPI::ConnectionId_t __attribute__((__unused__)) & /*connectionId*/) - { - return mRuntime->registerService(domain, instance, shStub, mContext); - } - +#if COMMONAPI_VERSION_NUMBER >= 300 + /** + * \brief Register stub objects. + * + * Example: std::shared_ptr 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 bool registerService(const std::shared_ptr & shStub, const std::string & domain, const std::string & instance, const CommonAPI::ConnectionId_t & connectionId) + { + return mRuntime->registerService(domain, instance, shStub, connectionId); + } +#endif /** * \brief Register stub objects. * @@ -191,93 +180,96 @@ public: return mRuntime->unregisterService(domain, interface, instance); } - /** - * \brief Deprecated method. Instead you should use bool registerService(const std::shared_ptr & shStub, const std::string & domain, const std::string & instance). - * - * Register stub objects. - * - * Example: std::shared_ptr 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 bool __attribute__((deprecated)) registerStub(const std::shared_ptr & shStub, const std::string & address) - { - std::vector 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 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> aProxy = buildProxy("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 class ProxyClass, typename ... AttributeExtensions> - std::shared_ptr> __attribute__((deprecated)) buildProxy(const std::string &domain, const std::string &instance, const CommonAPI::ConnectionId_t __attribute__((__unused__)) & /*connectionId*/) - { - return mRuntime->buildProxy(domain, instance, mContext); - } - - /** - * \brief Build proxy objects. - * - * Example: std::shared_ptr> aProxy = buildProxy("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. - */ + /** + * \brief Deprecated method. Instead you should use bool registerService(const std::shared_ptr & shStub, const std::string & domain, const std::string & instance). + * + * Register stub objects. + * + * Example: std::shared_ptr 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 bool __attribute__((deprecated)) registerStub(const std::shared_ptr & shStub, const std::string & address) + { + std::vector 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 parts = CommonAPI::split(address, ':'); + assert(parts.size()==3); + + return unregisterService(parts[0], parts[1], parts[2]); + } + +#if COMMONAPI_VERSION_NUMBER >= 300 + /** + * \brief Build proxy objects. + * + * Example: std::shared_ptr> aProxy = buildProxy("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 class ProxyClass, typename ... AttributeExtensions> + std::shared_ptr> buildProxy(const std::string &domain, const std::string &instance, const CommonAPI::ConnectionId_t & connectionId) + { + return mRuntime->buildProxy(domain, instance, connectionId); + } +#endif + + /** + * \brief Build proxy objects. + * + * Example: std::shared_ptr> aProxy = buildProxy("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 class ProxyClass, typename ... AttributeExtensions> std::shared_ptr> buildProxy(const std::string &domain, const std::string &instance) { return mRuntime->buildProxy(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> aProxy = buildProxy("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 class ProxyClass, typename ... AttributeExtensions> - std::shared_ptr> __attribute__((deprecated)) buildProxy(const std::string & address) - { - std::vector parts=CommonAPI::split(address, ':'); - assert(parts.size()==3); - - return buildProxy(parts[0], parts[2]); - } + + /** + * \brief Deprecated method. Instead you should use buildProxy(const std::string &domain, const std::string &instance). + * + * Build proxy objects. + * Example: std::shared_ptr> aProxy = buildProxy("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 class ProxyClass, typename ... AttributeExtensions> + std::shared_ptr> __attribute__((deprecated)) buildProxy(const std::string & address) + { + std::vector parts=CommonAPI::split(address, ':'); + assert(parts.size()==3); + + return buildProxy(parts[0], parts[2]); + } }; -- cgit v1.2.1