Add LocApiProxyBase to context
This is so that the izat adapters can get access to LocApiProxy through the context. Change-Id: I15a477d159375740047cd7386f8c8c5163fdaf87
This commit is contained in:
parent
6f3a9ac910
commit
a8dff29617
6 changed files with 47 additions and 34 deletions
|
@ -91,7 +91,8 @@ ContextBase::ContextBase(const MsgTask* msgTask,
|
||||||
const char* libName) :
|
const char* libName) :
|
||||||
mLBSProxy(getLBSProxy(libName)),
|
mLBSProxy(getLBSProxy(libName)),
|
||||||
mMsgTask(msgTask),
|
mMsgTask(msgTask),
|
||||||
mLocApi(createLocApi(exMask))
|
mLocApi(createLocApi(exMask)),
|
||||||
|
mLocApiProxy(mLocApi->getLocApiProxy())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ protected:
|
||||||
const LBSProxyBase* mLBSProxy;
|
const LBSProxyBase* mLBSProxy;
|
||||||
const MsgTask* mMsgTask;
|
const MsgTask* mMsgTask;
|
||||||
LocApiBase* mLocApi;
|
LocApiBase* mLocApi;
|
||||||
|
LocApiProxyBase *mLocApiProxy;
|
||||||
public:
|
public:
|
||||||
ContextBase(const MsgTask* msgTask,
|
ContextBase(const MsgTask* msgTask,
|
||||||
LOC_API_ADAPTER_EVENT_MASK_T exMask,
|
LOC_API_ADAPTER_EVENT_MASK_T exMask,
|
||||||
|
@ -55,6 +55,7 @@ public:
|
||||||
|
|
||||||
inline const MsgTask* getMsgTask() { return mMsgTask; }
|
inline const MsgTask* getMsgTask() { return mMsgTask; }
|
||||||
inline LocApiBase* getLocApi() { return mLocApi; }
|
inline LocApiBase* getLocApi() { return mLocApi; }
|
||||||
|
inline LocApiProxyBase* getLocApiProxy() { return mLocApiProxy; }
|
||||||
inline bool hasAgpsExt() { return mLBSProxy->hasAgpsExt(); }
|
inline bool hasAgpsExt() { return mLBSProxy->hasAgpsExt(); }
|
||||||
inline void requestUlp(LocAdapterBase* adapter,
|
inline void requestUlp(LocAdapterBase* adapter,
|
||||||
unsigned long capabilities) {
|
unsigned long capabilities) {
|
||||||
|
|
|
@ -36,26 +36,6 @@
|
||||||
|
|
||||||
namespace loc_core {
|
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
|
// This is the top level class, so the constructor will
|
||||||
// always gets called. Here we prepare for the default.
|
// always gets called. Here we prepare for the default.
|
||||||
// But if getLocApi(targetEnumType target) is overriden,
|
// 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),
|
mEvtMask(mask), mContext(context),
|
||||||
mLocApi(context->getLocApi()), mMsgTask(context->getMsgTask())
|
mLocApi(context->getLocApi()), mMsgTask(context->getMsgTask())
|
||||||
{
|
{
|
||||||
sendMsg(new LocOpenMsg(this, mLocApi));
|
mLocApi->addAdapter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocAdapterBase::
|
void LocAdapterBase::
|
||||||
|
|
|
@ -44,12 +44,10 @@ protected:
|
||||||
|
|
||||||
inline LocAdapterBase(const MsgTask* msgTask) :
|
inline LocAdapterBase(const MsgTask* msgTask) :
|
||||||
mEvtMask(0), mContext(NULL), mLocApi(NULL), mMsgTask(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,
|
LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
|
||||||
ContextBase* context);
|
ContextBase* context);
|
||||||
inline virtual ~LocAdapterBase() { mLocApi->removeAdapter(this); }
|
|
||||||
|
|
||||||
public:
|
|
||||||
inline LOC_API_ADAPTER_EVENT_MASK_T
|
inline LOC_API_ADAPTER_EVENT_MASK_T
|
||||||
checkMask(LOC_API_ADAPTER_EVENT_MASK_T mask) const {
|
checkMask(LOC_API_ADAPTER_EVENT_MASK_T mask) const {
|
||||||
return mEvtMask & mask;
|
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,
|
LocApiBase::LocApiBase(const MsgTask* msgTask,
|
||||||
LOC_API_ADAPTER_EVENT_MASK_T excludedMask) :
|
LOC_API_ADAPTER_EVENT_MASK_T excludedMask) :
|
||||||
mExcludedMask(excludedMask), mMsgTask(msgTask), mMask(0)
|
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++) {
|
for (int i = 0; i < MAX_ADAPTERS && mLocAdapters[i] != adapter; i++) {
|
||||||
if (mLocAdapters[i] == NULL) {
|
if (mLocAdapters[i] == NULL) {
|
||||||
mLocAdapters[i] = adapter;
|
mLocAdapters[i] = adapter;
|
||||||
open(mMask | (adapter->getEvtMask() & ~mExcludedMask));
|
mMsgTask->sendMsg(new LocOpenMsg(this,
|
||||||
|
(adapter->getEvtMask())));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,7 +195,7 @@ void LocApiBase::removeAdapter(LocAdapterBase* adapter)
|
||||||
close();
|
close();
|
||||||
} else {
|
} else {
|
||||||
// else we need to remove the bit
|
// 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()
|
void* LocApiBase :: getSibling()
|
||||||
DEFAULT_IMPL(NULL)
|
DEFAULT_IMPL(NULL)
|
||||||
void* LocApiBase :: getSibling2()
|
|
||||||
|
LocApiProxyBase* LocApiBase :: getLocApiProxy()
|
||||||
DEFAULT_IMPL(NULL)
|
DEFAULT_IMPL(NULL)
|
||||||
|
|
||||||
enum loc_api_adapter_err LocApiBase::
|
enum loc_api_adapter_err LocApiBase::
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <gps_extended.h>
|
#include <gps_extended.h>
|
||||||
#include <MsgTask.h>
|
#include <MsgTask.h>
|
||||||
#include <log_util.h>
|
#include <log_util.h>
|
||||||
|
|
||||||
namespace loc_core {
|
namespace loc_core {
|
||||||
|
|
||||||
int hexcode(char *hexstring, int string_size,
|
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) \
|
#define TO_1ST_HANDLING_ADAPTER(adapters, call) \
|
||||||
for (int i = 0; i <MAX_ADAPTERS && NULL != (adapters)[i] && !(call); i++);
|
for (int i = 0; i <MAX_ADAPTERS && NULL != (adapters)[i] && !(call); i++);
|
||||||
|
|
||||||
|
|
||||||
class LocAdapterBase;
|
class LocAdapterBase;
|
||||||
struct LocSsrMsg;
|
struct LocSsrMsg;
|
||||||
|
struct LocOpenMsg;
|
||||||
|
|
||||||
|
class LocApiProxyBase {
|
||||||
|
public:
|
||||||
|
inline LocApiProxyBase() {}
|
||||||
|
inline virtual ~LocApiProxyBase() {}
|
||||||
|
inline virtual void* getSibling2() { return NULL; }
|
||||||
|
};
|
||||||
|
|
||||||
class LocApiBase {
|
class LocApiBase {
|
||||||
friend struct LocSsrMsg;
|
friend struct LocSsrMsg;
|
||||||
|
//LocOpenMsg calls open() which makes it necessary to declare
|
||||||
|
//it as a friend
|
||||||
|
friend struct LocOpenMsg;
|
||||||
friend class ContextBase;
|
friend class ContextBase;
|
||||||
const LOC_API_ADAPTER_EVENT_MASK_T mExcludedMask;
|
|
||||||
const MsgTask* mMsgTask;
|
const MsgTask* mMsgTask;
|
||||||
|
|
||||||
LocAdapterBase* mLocAdapters[MAX_ADAPTERS];
|
LocAdapterBase* mLocAdapters[MAX_ADAPTERS];
|
||||||
|
@ -68,13 +78,13 @@ protected:
|
||||||
open(LOC_API_ADAPTER_EVENT_MASK_T mask);
|
open(LOC_API_ADAPTER_EVENT_MASK_T mask);
|
||||||
virtual enum loc_api_adapter_err
|
virtual enum loc_api_adapter_err
|
||||||
close();
|
close();
|
||||||
|
|
||||||
LOC_API_ADAPTER_EVENT_MASK_T getEvtMask();
|
LOC_API_ADAPTER_EVENT_MASK_T getEvtMask();
|
||||||
LOC_API_ADAPTER_EVENT_MASK_T mMask;
|
LOC_API_ADAPTER_EVENT_MASK_T mMask;
|
||||||
LocApiBase(const MsgTask* msgTask,
|
LocApiBase(const MsgTask* msgTask,
|
||||||
LOC_API_ADAPTER_EVENT_MASK_T excludedMask);
|
LOC_API_ADAPTER_EVENT_MASK_T excludedMask);
|
||||||
inline virtual ~LocApiBase() { close(); }
|
inline virtual ~LocApiBase() { close(); }
|
||||||
bool isInSession();
|
bool isInSession();
|
||||||
|
const LOC_API_ADAPTER_EVENT_MASK_T mExcludedMask;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void addAdapter(LocAdapterBase* adapter);
|
void addAdapter(LocAdapterBase* adapter);
|
||||||
|
@ -111,7 +121,7 @@ public:
|
||||||
// RPC, QMI, etc. The default implementation is empty.
|
// RPC, QMI, etc. The default implementation is empty.
|
||||||
|
|
||||||
virtual void* getSibling();
|
virtual void* getSibling();
|
||||||
virtual void* getSibling2();
|
virtual LocApiProxyBase* getLocApiProxy();
|
||||||
virtual enum loc_api_adapter_err
|
virtual enum loc_api_adapter_err
|
||||||
startFix(const LocPosMode& posMode);
|
startFix(const LocPosMode& posMode);
|
||||||
virtual enum loc_api_adapter_err
|
virtual enum loc_api_adapter_err
|
||||||
|
|
Loading…
Reference in a new issue