19 #ifndef COMMONAPIWRAPPER_H_ 20 #define COMMONAPIWRAPPER_H_ 28 #include <CommonAPI/CommonAPI.hpp> 29 #ifndef COMMONAPI_INTERNAL_COMPILATION 30 #define COMMONAPI_INTERNAL_COMPILATION 31 #include <CommonAPI/MainLoopContext.hpp> 32 #undef COMMONAPI_INTERNAL_COMPILATION 34 #include <CommonAPI/Utils.hpp> 35 #include "audiomanagerconfig.h" 47 class CAmSocketHandler;
51 void commonPrepareCallback(
const sh_pollHandle_t handle,
void* userData);
54 bool commonDispatchCallback(
const sh_pollHandle_t handle,
void* userData);
57 void commonFireCallback(
const pollfd pollfd,
const sh_pollHandle_t,
void*);
69 CommonAPI::Timeout* timeout;
74 std::shared_ptr<CommonAPI::Runtime> mRuntime;
75 std::shared_ptr<CommonAPI::MainLoopContext> mContext;
77 CommonAPI::DispatchSourceListenerSubscription mDispatchSourceListenerSubscription;
78 CommonAPI::WatchListenerSubscription mWatchListenerSubscription;
79 CommonAPI::TimeoutSourceListenerSubscription mTimeoutSourceListenerSubscription;
80 CommonAPI::WakeupListenerSubscription mWakeupListenerSubscription;
81 std::multimap<CommonAPI::DispatchPriority, CommonAPI::DispatchSource*> mRegisteredDispatchSources;
82 std::map<int,CommonAPI::Watch*> mMapWatches;
83 CommonAPI::Watch* mWatchToCheck;
84 std::list<CommonAPI::DispatchSource*> mSourcesToDispatch;
85 std::vector<timerHandles> mpListTimerhandles;
87 void registerDispatchSource(CommonAPI::DispatchSource* dispatchSource,
const CommonAPI::DispatchPriority dispatchPriority);
88 void deregisterDispatchSource(CommonAPI::DispatchSource* dispatchSource);
89 void registerWatch(CommonAPI::Watch* watch,
const CommonAPI::DispatchPriority dispatchPriority);
90 void deregisterWatch(CommonAPI::Watch* watch);
91 void registerTimeout(CommonAPI::Timeout* timeout,
const CommonAPI::DispatchPriority dispatchPriority);
92 void deregisterTimeout(CommonAPI::Timeout* timeout);
136 #if COMMONAPI_VERSION_NUMBER >= 300 149 template <
class TStubImp>
bool registerService(
const std::shared_ptr<TStubImp> & shStub,
const std::string & domain,
const std::string & instance,
const CommonAPI::ConnectionId_t & connectionId)
151 return mRuntime->registerService(domain, instance, shStub, connectionId);
165 template <
class TStubImp>
bool registerService(
const std::shared_ptr<TStubImp> & shStub,
const std::string & domain,
const std::string & instance)
167 return mRuntime->registerService(domain, instance, shStub, mContext);
178 bool unregisterService(
const std::string &domain,
const std::string &interface,
const std::string &instance)
180 return mRuntime->unregisterService(domain, interface, instance);
195 template <
class TStubImp>
bool __attribute__((deprecated)) registerStub(const
std::shared_ptr<TStubImp> & shStub, const
std::
string & address)
197 std::vector<std::string> parts = CommonAPI::split(address,
':');
198 assert(parts.size()==3);
213 std::vector<std::string> parts = CommonAPI::split(address,
':');
214 assert(parts.size()==3);
219 #if COMMONAPI_VERSION_NUMBER >= 300 231 template<
template<
typename ...>
class ProxyClass,
typename ... AttributeExtensions>
232 std::shared_ptr<ProxyClass<AttributeExtensions...>>
buildProxy(
const std::string &domain,
const std::string &instance,
const CommonAPI::ConnectionId_t & connectionId)
234 return mRuntime->buildProxy<ProxyClass>(domain, instance, connectionId);
248 template<
template<
typename ...>
class ProxyClass,
typename ... AttributeExtensions>
249 std::shared_ptr<ProxyClass<AttributeExtensions...>>
buildProxy(
const std::string &domain,
const std::string &instance)
251 return mRuntime->buildProxy<ProxyClass>(domain, instance, mContext);
265 template<
template<
typename ...>
class ProxyClass,
typename ... AttributeExtensions>
268 std::vector<std::string> parts=CommonAPI::split(address,
':');
269 assert(parts.size()==3);
271 return buildProxy<ProxyClass>(parts[0], parts[2]);
281 #define AMCAPI getCAPI() 285 #define AM_CAPI getCAPI() 289 #define CAPI getCAPI() CAmCommonAPIWrapper(CAmSocketHandler *socketHandler, const std::string &applicationName="")
A Common-API wrapper class, which loads the common-api runtime and instantiates all necessary objects...
bool __attribute__((deprecated)) registerStub(const std
Deprecated method.
bool unregisterService(const std::string &domain, const std::string &interface, const std::string &instance)
Unregister stub objects.
make private, not public template for a callback
static CAmCommonAPIWrapper * instantiateOnce(CAmSocketHandler *socketHandler, const std::string &applicationName="")
Creates a singleton instance attached to the provided socket handler object.
The am::CAmSocketHandler implements a mainloop for the AudioManager.
uint16_t sh_pollHandle_t
this is a handle for a filedescriptor to be used with the SocketHandler
std::shared_ptr< ProxyClass< AttributeExtensions... > > buildProxy(const std::string &domain, const std::string &instance)
Build proxy objects.
static void deleteInstance()
Deletes the instanciated object.
virtual ~CAmCommonAPIWrapper()
static CAmCommonAPIWrapper * getInstance()
Returns an already instantiated object.
std::shared_ptr< ProxyClass< AttributeExtensions... > > __attribute__((deprecated)) buildProxy(const std
Deprecated method.
CAmSocketHandler * getSocketHandler() const
Getter for the socket handler.
SPDX license identifier: MPL-2.0.
bool __attribute__((deprecated)) unregisterStub(const std
Deprecated method.
bool registerService(const std::shared_ptr< TStubImp > &shStub, const std::string &domain, const std::string &instance)
Register stub objects.
sh_pollHandle_t sh_timerHandle_t
this is a handle for a timer to be used with the SocketHandler
template to create the functor for a class