Merge "Add LocApiProxyBase to context"
This commit is contained in:
commit
d32cd2946d
6 changed files with 47 additions and 34 deletions
|
@ -91,7 +91,8 @@ ContextBase::ContextBase(const MsgTask* msgTask,
|
|||
const char* libName) :
|
||||
mLBSProxy(getLBSProxy(libName)),
|
||||
mMsgTask(msgTask),
|
||||
mLocApi(createLocApi(exMask))
|
||||
mLocApi(createLocApi(exMask)),
|
||||
mLocApiProxy(mLocApi->getLocApiProxy())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ protected:
|
|||
const LBSProxyBase* mLBSProxy;
|
||||
const MsgTask* mMsgTask;
|
||||
LocApiBase* mLocApi;
|
||||
|
||||
LocApiProxyBase *mLocApiProxy;
|
||||
public:
|
||||
ContextBase(const MsgTask* msgTask,
|
||||
LOC_API_ADAPTER_EVENT_MASK_T exMask,
|
||||
|
@ -55,6 +55,7 @@ public:
|
|||
|
||||
inline const MsgTask* getMsgTask() { return mMsgTask; }
|
||||
inline LocApiBase* getLocApi() { return mLocApi; }
|
||||
inline LocApiProxyBase* getLocApiProxy() { return mLocApiProxy; }
|
||||
inline bool hasAgpsExt() { return mLBSProxy->hasAgpsExt(); }
|
||||
inline void requestUlp(LocAdapterBase* adapter,
|
||||
unsigned long capabilities) {
|
||||
|
|
|
@ -36,26 +36,6 @@
|
|||
|
||||
namespace loc_core {
|
||||
|
||||
struct LocOpenMsg : public LocMsg {
|
||||
LocAdapterBase* mLocAdapter;
|
||||
LocApiBase* mLocApi;
|
||||
inline LocOpenMsg(LocAdapterBase* locAdapter,
|
||||
LocApiBase* locApi) :
|
||||
LocMsg(), mLocAdapter(locAdapter), mLocApi(locApi)
|
||||
{
|
||||
locallog();
|
||||
}
|
||||
inline virtual void proc() const {
|
||||
mLocApi->addAdapter(mLocAdapter);
|
||||
}
|
||||
inline void locallog() {
|
||||
LOC_LOGV("LocOpen");
|
||||
}
|
||||
inline virtual void log() {
|
||||
locallog();
|
||||
}
|
||||
};
|
||||
|
||||
// This is the top level class, so the constructor will
|
||||
// always gets called. Here we prepare for the default.
|
||||
// But if getLocApi(targetEnumType target) is overriden,
|
||||
|
@ -65,7 +45,7 @@ LocAdapterBase::LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
|
|||
mEvtMask(mask), mContext(context),
|
||||
mLocApi(context->getLocApi()), mMsgTask(context->getMsgTask())
|
||||
{
|
||||
sendMsg(new LocOpenMsg(this, mLocApi));
|
||||
mLocApi->addAdapter(this);
|
||||
}
|
||||
|
||||
void LocAdapterBase::
|
||||
|
|
|
@ -44,12 +44,10 @@ protected:
|
|||
|
||||
inline LocAdapterBase(const MsgTask* msgTask) :
|
||||
mEvtMask(0), mContext(NULL), mLocApi(NULL), mMsgTask(msgTask) {}
|
||||
|
||||
public:
|
||||
inline virtual ~LocAdapterBase() { mLocApi->removeAdapter(this); }
|
||||
LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
|
||||
ContextBase* context);
|
||||
inline virtual ~LocAdapterBase() { mLocApi->removeAdapter(this); }
|
||||
|
||||
public:
|
||||
inline LOC_API_ADAPTER_EVENT_MASK_T
|
||||
checkMask(LOC_API_ADAPTER_EVENT_MASK_T mask) const {
|
||||
return mEvtMask & mask;
|
||||
|
|
|
@ -103,6 +103,27 @@ struct LocSsrMsg : public LocMsg {
|
|||
}
|
||||
};
|
||||
|
||||
struct LocOpenMsg : public LocMsg {
|
||||
LocApiBase* mLocApi;
|
||||
LOC_API_ADAPTER_EVENT_MASK_T mMask;
|
||||
inline LocOpenMsg(LocApiBase* locApi,
|
||||
LOC_API_ADAPTER_EVENT_MASK_T mask) :
|
||||
LocMsg(), mLocApi(locApi), mMask(mask)
|
||||
{
|
||||
locallog();
|
||||
}
|
||||
inline virtual void proc() const {
|
||||
mLocApi->open(mMask);
|
||||
}
|
||||
inline void locallog() {
|
||||
LOC_LOGV("%s:%d]: LocOpen Mask: %x\n",
|
||||
__func__, __LINE__, mMask);
|
||||
}
|
||||
inline virtual void log() {
|
||||
locallog();
|
||||
}
|
||||
};
|
||||
|
||||
LocApiBase::LocApiBase(const MsgTask* msgTask,
|
||||
LOC_API_ADAPTER_EVENT_MASK_T excludedMask) :
|
||||
mExcludedMask(excludedMask), mMsgTask(msgTask), mMask(0)
|
||||
|
@ -137,7 +158,8 @@ void LocApiBase::addAdapter(LocAdapterBase* adapter)
|
|||
for (int i = 0; i < MAX_ADAPTERS && mLocAdapters[i] != adapter; i++) {
|
||||
if (mLocAdapters[i] == NULL) {
|
||||
mLocAdapters[i] = adapter;
|
||||
open(mMask | (adapter->getEvtMask() & ~mExcludedMask));
|
||||
mMsgTask->sendMsg(new LocOpenMsg(this,
|
||||
(adapter->getEvtMask())));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -173,7 +195,7 @@ void LocApiBase::removeAdapter(LocAdapterBase* adapter)
|
|||
close();
|
||||
} else {
|
||||
// else we need to remove the bit
|
||||
open(getEvtMask() & ~mExcludedMask);
|
||||
mMsgTask->sendMsg(new LocOpenMsg(this, getEvtMask()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -298,7 +320,8 @@ void LocApiBase::requestNiNotify(GpsNiNotification ¬ify, const void* data)
|
|||
|
||||
void* LocApiBase :: getSibling()
|
||||
DEFAULT_IMPL(NULL)
|
||||
void* LocApiBase :: getSibling2()
|
||||
|
||||
LocApiProxyBase* LocApiBase :: getLocApiProxy()
|
||||
DEFAULT_IMPL(NULL)
|
||||
|
||||
enum loc_api_adapter_err LocApiBase::
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <gps_extended.h>
|
||||
#include <MsgTask.h>
|
||||
#include <log_util.h>
|
||||
|
||||
namespace loc_core {
|
||||
|
||||
int hexcode(char *hexstring, int string_size,
|
||||
|
@ -51,14 +52,23 @@ int decodeAddress(char *addr_string, int string_size,
|
|||
#define TO_1ST_HANDLING_ADAPTER(adapters, call) \
|
||||
for (int i = 0; i <MAX_ADAPTERS && NULL != (adapters)[i] && !(call); i++);
|
||||
|
||||
|
||||
class LocAdapterBase;
|
||||
struct LocSsrMsg;
|
||||
struct LocOpenMsg;
|
||||
|
||||
class LocApiProxyBase {
|
||||
public:
|
||||
inline LocApiProxyBase() {}
|
||||
inline virtual ~LocApiProxyBase() {}
|
||||
inline virtual void* getSibling2() { return NULL; }
|
||||
};
|
||||
|
||||
class LocApiBase {
|
||||
friend struct LocSsrMsg;
|
||||
//LocOpenMsg calls open() which makes it necessary to declare
|
||||
//it as a friend
|
||||
friend struct LocOpenMsg;
|
||||
friend class ContextBase;
|
||||
const LOC_API_ADAPTER_EVENT_MASK_T mExcludedMask;
|
||||
const MsgTask* mMsgTask;
|
||||
|
||||
LocAdapterBase* mLocAdapters[MAX_ADAPTERS];
|
||||
|
@ -68,13 +78,13 @@ protected:
|
|||
open(LOC_API_ADAPTER_EVENT_MASK_T mask);
|
||||
virtual enum loc_api_adapter_err
|
||||
close();
|
||||
|
||||
LOC_API_ADAPTER_EVENT_MASK_T getEvtMask();
|
||||
LOC_API_ADAPTER_EVENT_MASK_T mMask;
|
||||
LocApiBase(const MsgTask* msgTask,
|
||||
LOC_API_ADAPTER_EVENT_MASK_T excludedMask);
|
||||
inline virtual ~LocApiBase() { close(); }
|
||||
bool isInSession();
|
||||
const LOC_API_ADAPTER_EVENT_MASK_T mExcludedMask;
|
||||
|
||||
public:
|
||||
void addAdapter(LocAdapterBase* adapter);
|
||||
|
@ -111,7 +121,7 @@ public:
|
|||
// RPC, QMI, etc. The default implementation is empty.
|
||||
|
||||
virtual void* getSibling();
|
||||
virtual void* getSibling2();
|
||||
virtual LocApiProxyBase* getLocApiProxy();
|
||||
virtual enum loc_api_adapter_err
|
||||
startFix(const LocPosMode& posMode);
|
||||
virtual enum loc_api_adapter_err
|
||||
|
|
Loading…
Reference in a new issue