sanders: gps: update to LA.UM.7.6.r1-02000-89xx.0 tag
This commit is contained in:
496
gps/core/data-items/DataItemConcreteTypesBase.h
Normal file
496
gps/core/data-items/DataItemConcreteTypesBase.h
Normal file
@@ -0,0 +1,496 @@
|
||||
/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __DATAITEMCONCRETEBASETYPES__
|
||||
#define __DATAITEMCONCRETEBASETYPES__
|
||||
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <DataItemId.h>
|
||||
#include <IDataItemCore.h>
|
||||
|
||||
#define MAC_ADDRESS_LENGTH 6
|
||||
// MAC address length in bytes
|
||||
// QMI_LOC_SRN_MAC_ADDR_LENGTH_V02
|
||||
#define SRN_MAC_ADDRESS_LENGTH 6
|
||||
#define WIFI_SUPPLICANT_DEFAULT_STATE 0
|
||||
|
||||
namespace loc_core
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
class AirplaneModeDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
AirplaneModeDataItemBase(bool mode):
|
||||
mMode(mode),
|
||||
mId(AIRPLANEMODE_DATA_ITEM_ID) {}
|
||||
virtual ~AirplaneModeDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
bool mMode;
|
||||
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class ENHDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
ENHDataItemBase(bool enabled) :
|
||||
mEnabled(enabled),
|
||||
mId(ENH_DATA_ITEM_ID) {}
|
||||
virtual ~ENHDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
bool mEnabled;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class GPSStateDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
GPSStateDataItemBase(bool enabled) :
|
||||
mEnabled(enabled),
|
||||
mId(GPSSTATE_DATA_ITEM_ID) {}
|
||||
virtual ~GPSStateDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
bool mEnabled;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class NLPStatusDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
NLPStatusDataItemBase(bool enabled) :
|
||||
mEnabled(enabled),
|
||||
mId(NLPSTATUS_DATA_ITEM_ID) {}
|
||||
virtual ~NLPStatusDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
bool mEnabled;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class WifiHardwareStateDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
WifiHardwareStateDataItemBase(bool enabled) :
|
||||
mEnabled(enabled),
|
||||
mId(WIFIHARDWARESTATE_DATA_ITEM_ID) {}
|
||||
virtual ~WifiHardwareStateDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
bool mEnabled;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class ScreenStateDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
ScreenStateDataItemBase(bool state) :
|
||||
mState(state),
|
||||
mId(SCREEN_STATE_DATA_ITEM_ID) {}
|
||||
virtual ~ScreenStateDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
bool mState;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class PowerConnectStateDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
PowerConnectStateDataItemBase(bool state) :
|
||||
mState(state),
|
||||
mId(POWER_CONNECTED_STATE_DATA_ITEM_ID) {}
|
||||
virtual ~PowerConnectStateDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
bool mState;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class TimeZoneChangeDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
TimeZoneChangeDataItemBase(int64_t currTimeMillis, int32_t rawOffset, int32_t dstOffset) :
|
||||
mCurrTimeMillis (currTimeMillis),
|
||||
mRawOffsetTZ (rawOffset),
|
||||
mDstOffsetTZ (dstOffset),
|
||||
mId(TIMEZONE_CHANGE_DATA_ITEM_ID) {}
|
||||
virtual ~TimeZoneChangeDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
int64_t mCurrTimeMillis;
|
||||
int32_t mRawOffsetTZ;
|
||||
int32_t mDstOffsetTZ;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class TimeChangeDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
TimeChangeDataItemBase(int64_t currTimeMillis, int32_t rawOffset, int32_t dstOffset) :
|
||||
mCurrTimeMillis (currTimeMillis),
|
||||
mRawOffsetTZ (rawOffset),
|
||||
mDstOffsetTZ (dstOffset),
|
||||
mId(TIME_CHANGE_DATA_ITEM_ID) {}
|
||||
virtual ~TimeChangeDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
int64_t mCurrTimeMillis;
|
||||
int32_t mRawOffsetTZ;
|
||||
int32_t mDstOffsetTZ;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class ShutdownStateDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
ShutdownStateDataItemBase(bool state) :
|
||||
mState (state),
|
||||
mId(SHUTDOWN_STATE_DATA_ITEM_ID) {}
|
||||
virtual ~ShutdownStateDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
bool mState;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class AssistedGpsDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
AssistedGpsDataItemBase(bool enabled) :
|
||||
mEnabled(enabled),
|
||||
mId(ASSISTED_GPS_DATA_ITEM_ID) {}
|
||||
virtual ~AssistedGpsDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
bool mEnabled;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class NetworkInfoDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
enum NetworkType {
|
||||
TYPE_MOBILE,
|
||||
TYPE_WIFI,
|
||||
TYPE_ETHERNET,
|
||||
TYPE_BLUETOOTH,
|
||||
TYPE_MMS,
|
||||
TYPE_SUPL,
|
||||
TYPE_DUN,
|
||||
TYPE_HIPRI,
|
||||
TYPE_WIMAX,
|
||||
TYPE_UNKNOWN,
|
||||
};
|
||||
NetworkInfoDataItemBase(
|
||||
NetworkType initialType, int32_t type, string typeName, string subTypeName,
|
||||
bool available, bool connected, bool roaming ):
|
||||
mAllTypes(typeToAllTypes(initialType)),
|
||||
mType(type),
|
||||
mTypeName(typeName),
|
||||
mSubTypeName(subTypeName),
|
||||
mAvailable(available),
|
||||
mConnected(connected),
|
||||
mRoaming(roaming),
|
||||
mId(NETWORKINFO_DATA_ITEM_ID) {}
|
||||
virtual ~NetworkInfoDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
inline virtual NetworkType getType(void) const {
|
||||
return (NetworkType)mType;
|
||||
}
|
||||
inline uint64_t getAllTypes() { return mAllTypes; }
|
||||
// Data members
|
||||
uint64_t mAllTypes;
|
||||
int32_t mType;
|
||||
string mTypeName;
|
||||
string mSubTypeName;
|
||||
bool mAvailable;
|
||||
bool mConnected;
|
||||
bool mRoaming;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
inline uint64_t typeToAllTypes(NetworkType type) {
|
||||
return (type >= TYPE_UNKNOWN || type < TYPE_MOBILE) ? 0 : (1<<type);
|
||||
}
|
||||
};
|
||||
|
||||
class ServiceStatusDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
ServiceStatusDataItemBase(int32_t serviceState) :
|
||||
mServiceState (serviceState),
|
||||
mId(SERVICESTATUS_DATA_ITEM_ID) {}
|
||||
virtual ~ServiceStatusDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
int32_t mServiceState;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class ModelDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
ModelDataItemBase(const string & name) :
|
||||
mModel (name),
|
||||
mId(MODEL_DATA_ITEM_ID) {}
|
||||
virtual ~ModelDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
string mModel;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class ManufacturerDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
ManufacturerDataItemBase(const string & name) :
|
||||
mManufacturer (name),
|
||||
mId(MANUFACTURER_DATA_ITEM_ID) {}
|
||||
virtual ~ManufacturerDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
string mManufacturer;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class RilServiceInfoDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
inline RilServiceInfoDataItemBase() :
|
||||
mData(nullptr), mId(RILSERVICEINFO_DATA_ITEM_ID) {}
|
||||
inline virtual ~RilServiceInfoDataItemBase() { if (nullptr != mData) free(mData); }
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
inline RilServiceInfoDataItemBase(const RilServiceInfoDataItemBase& peer) :
|
||||
RilServiceInfoDataItemBase() {
|
||||
peer.setPeerData(*this);
|
||||
}
|
||||
inline virtual bool operator==(const RilServiceInfoDataItemBase& other) const {
|
||||
return other.mData == mData;
|
||||
}
|
||||
inline virtual void setPeerData(RilServiceInfoDataItemBase& /*peer*/) const {}
|
||||
void* mData;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class RilCellInfoDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
inline RilCellInfoDataItemBase() :
|
||||
mData(nullptr), mId(RILCELLINFO_DATA_ITEM_ID) {}
|
||||
inline virtual ~RilCellInfoDataItemBase() { if (nullptr != mData) free(mData); }
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
inline RilCellInfoDataItemBase(const RilCellInfoDataItemBase& peer) :
|
||||
RilCellInfoDataItemBase() {
|
||||
peer.setPeerData(*this);
|
||||
}
|
||||
inline virtual bool operator==(const RilCellInfoDataItemBase& other) const {
|
||||
return other.mData == mData;
|
||||
}
|
||||
inline virtual void setPeerData(RilCellInfoDataItemBase& /*peer*/) const {}
|
||||
void* mData;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class WifiSupplicantStatusDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
WifiSupplicantStatusDataItemBase() :
|
||||
mState((WifiSupplicantState)WIFI_SUPPLICANT_DEFAULT_STATE),
|
||||
mApMacAddressValid(false),
|
||||
mWifiApSsidValid(false),
|
||||
mId(WIFI_SUPPLICANT_STATUS_DATA_ITEM_ID) {
|
||||
memset (&mApMacAddress, 0, sizeof (mApMacAddress));
|
||||
mWifiApSsid.clear();
|
||||
}
|
||||
virtual ~WifiSupplicantStatusDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
typedef enum WifiSupplicantState {
|
||||
DISCONNECTED,
|
||||
INTERFACE_DISABLED,
|
||||
INACTIVE,
|
||||
SCANNING,
|
||||
AUTHENTICATING,
|
||||
ASSOCIATING,
|
||||
ASSOCIATED,
|
||||
FOUR_WAY_HANDSHAKE,
|
||||
GROUP_HANDSHAKE,
|
||||
COMPLETED,
|
||||
DORMANT,
|
||||
UNINITIALIZED,
|
||||
INVALID
|
||||
} WifiSupplicantState;
|
||||
/* Represents whether access point attach state*/
|
||||
WifiSupplicantState mState;
|
||||
/* Represents info on whether ap mac address is valid */
|
||||
bool mApMacAddressValid;
|
||||
/* Represents mac address of the wifi access point*/
|
||||
uint8_t mApMacAddress[MAC_ADDRESS_LENGTH];
|
||||
/* Represents info on whether ap SSID is valid */
|
||||
bool mWifiApSsidValid;
|
||||
/* Represents Wifi SSID string*/
|
||||
string mWifiApSsid;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class TacDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
TacDataItemBase(const string & name) :
|
||||
mValue (name),
|
||||
mId(TAC_DATA_ITEM_ID) {}
|
||||
virtual ~TacDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
string mValue;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class MccmncDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
MccmncDataItemBase(const string & name) :
|
||||
mValue(name),
|
||||
mId(MCCMNC_DATA_ITEM_ID) {}
|
||||
virtual ~MccmncDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
// Data members
|
||||
string mValue;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class SrnDeviceScanDetailsDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
SrnDeviceScanDetailsDataItemBase(DataItemId Id) :
|
||||
mValidSrnData(false),
|
||||
mApSrnRssi(-1),
|
||||
mApSrnTimestamp(0),
|
||||
mRequestTimestamp(0),
|
||||
mReceiveTimestamp(0),
|
||||
mErrorCause(-1),
|
||||
mId(Id) {}
|
||||
virtual ~SrnDeviceScanDetailsDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
// Data members common to all SRN tech types
|
||||
/* Represents info on whether SRN data is valid (no error)*/
|
||||
bool mValidSrnData;
|
||||
/* SRN device RSSI reported */
|
||||
int32_t mApSrnRssi;
|
||||
/* MAC adress of SRN device */
|
||||
uint8_t mApSrnMacAddress[SRN_MAC_ADDRESS_LENGTH];
|
||||
/* UTC timestamp at which the scan was requested.for this SRN device*/
|
||||
int64_t mApSrnTimestamp;
|
||||
/* UTC timestamp at which the scan was started. */
|
||||
int64_t mRequestTimestamp;
|
||||
/* UTC timestamp at which the scan was received.*/
|
||||
int64_t mReceiveTimestamp;
|
||||
/* Reason for the error/failure if SRN details are not valid */
|
||||
int32_t mErrorCause;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
class BtDeviceScanDetailsDataItemBase : public SrnDeviceScanDetailsDataItemBase {
|
||||
|
||||
public:
|
||||
BtDeviceScanDetailsDataItemBase() :
|
||||
SrnDeviceScanDetailsDataItemBase(BT_SCAN_DATA_ITEM_ID) {}
|
||||
virtual ~BtDeviceScanDetailsDataItemBase() {}
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
};
|
||||
|
||||
class BtLeDeviceScanDetailsDataItemBase : public SrnDeviceScanDetailsDataItemBase {
|
||||
|
||||
public:
|
||||
BtLeDeviceScanDetailsDataItemBase() :
|
||||
SrnDeviceScanDetailsDataItemBase(BTLE_SCAN_DATA_ITEM_ID) {}
|
||||
virtual ~BtLeDeviceScanDetailsDataItemBase() {}
|
||||
virtual void stringify(string& /*valueStr*/) {}
|
||||
virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;}
|
||||
};
|
||||
|
||||
class BatteryLevelDataItemBase : public IDataItemCore {
|
||||
public:
|
||||
inline BatteryLevelDataItemBase(uint8_t batteryPct) :
|
||||
mBatteryPct(batteryPct), mId(BATTERY_LEVEL_DATA_ITEM_ID) {}
|
||||
inline ~BatteryLevelDataItemBase() {}
|
||||
inline virtual DataItemId getId() { return mId; }
|
||||
// Data members
|
||||
uint8_t mBatteryPct;
|
||||
protected:
|
||||
DataItemId mId;
|
||||
};
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
#endif //__DATAITEMCONCRETEBASETYPES__
|
||||
@@ -67,7 +67,13 @@ typedef enum e_DataItemId {
|
||||
BTLE_SCAN_DATA_ITEM_ID,
|
||||
BT_SCAN_DATA_ITEM_ID,
|
||||
OEM_GTP_UPLOAD_TRIGGER_READY_ITEM_ID,
|
||||
MAX_DATA_ITEM_ID
|
||||
|
||||
MAX_DATA_ITEM_ID,
|
||||
|
||||
// 26 -
|
||||
BATTERY_LEVEL_DATA_ITEM_ID,
|
||||
|
||||
MAX_DATA_ITEM_ID_1_1,
|
||||
} DataItemId;
|
||||
|
||||
#endif // #ifndef __DATAITEMID_H__
|
||||
|
||||
@@ -32,7 +32,8 @@
|
||||
#include <DataItemId.h>
|
||||
#include <IDataItemCore.h>
|
||||
#include <DataItemsFactoryProxy.h>
|
||||
#include <platform_lib_log_util.h>
|
||||
#include <loc_pla.h>
|
||||
#include <log_util.h>
|
||||
|
||||
namespace loc_core
|
||||
{
|
||||
@@ -68,7 +69,7 @@ IDataItemCore* DataItemsFactoryProxy::createNewDataItem(DataItemId id)
|
||||
getConcreteDIFunc = (get_concrete_data_item_fn * )
|
||||
dlsym(dataItemLibHandle, DATA_ITEMS_GET_CONCRETE_DI);
|
||||
if (NULL != getConcreteDIFunc) {
|
||||
LOC_LOGD("Loaded function %s : %x",DATA_ITEMS_GET_CONCRETE_DI,getConcreteDIFunc);
|
||||
LOC_LOGD("Loaded function %s : %p",DATA_ITEMS_GET_CONCRETE_DI,getConcreteDIFunc);
|
||||
mydi = (*getConcreteDIFunc)(id);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
/* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <platform_lib_log_util.h>
|
||||
#include <ClientIndex.h>
|
||||
#include <IDataItemObserver.h>
|
||||
#include <DataItemId.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace loc_core;
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
inline ClientIndex <CT,DIT> :: ClientIndex () {}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
inline ClientIndex <CT,DIT> :: ~ClientIndex () {}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
bool ClientIndex <CT,DIT> :: isSubscribedClient (CT client) {
|
||||
bool result = false;
|
||||
ENTRY_LOG ();
|
||||
typename map < CT, list <DIT> > :: iterator it =
|
||||
mDataItemsPerClientMap.find (client);
|
||||
if (it != mDataItemsPerClientMap.end ()) {
|
||||
result = true;
|
||||
}
|
||||
EXIT_LOG_WITH_ERROR ("%d",result);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
void ClientIndex <CT,DIT> :: getSubscribedList (CT client, list <DIT> & out) {
|
||||
ENTRY_LOG ();
|
||||
typename map < CT, list <DIT> > :: iterator it =
|
||||
mDataItemsPerClientMap.find (client);
|
||||
if (it != mDataItemsPerClientMap.end ()) {
|
||||
out = it->second;
|
||||
}
|
||||
EXIT_LOG_WITH_ERROR ("%d",0);
|
||||
}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
int ClientIndex <CT,DIT> :: remove (CT client) {
|
||||
int result = 0;
|
||||
ENTRY_LOG ();
|
||||
mDataItemsPerClientMap.erase (client);
|
||||
EXIT_LOG_WITH_ERROR ("%d",result);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
void ClientIndex <CT,DIT> :: remove (const list <DIT> & r, list <CT> & out) {
|
||||
ENTRY_LOG ();
|
||||
typename map < CT, list <DIT> > :: iterator dicIter =
|
||||
mDataItemsPerClientMap.begin ();
|
||||
while (dicIter != mDataItemsPerClientMap.end()) {
|
||||
typename list <DIT> :: const_iterator it = r.begin ();
|
||||
for (; it != r.end (); ++it) {
|
||||
typename list <DIT> :: iterator iter =
|
||||
find (dicIter->second.begin (), dicIter->second.end (), *it);
|
||||
if (iter != dicIter->second.end ()) {
|
||||
dicIter->second.erase (iter);
|
||||
}
|
||||
}
|
||||
if (dicIter->second.empty ()) {
|
||||
out.push_back (dicIter->first);
|
||||
// Post-increment operator increases the iterator but returns the
|
||||
// prevous one that will be invalidated by erase()
|
||||
mDataItemsPerClientMap.erase (dicIter++);
|
||||
} else {
|
||||
++dicIter;
|
||||
}
|
||||
}
|
||||
EXIT_LOG_WITH_ERROR ("%d",0);
|
||||
}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
void ClientIndex <CT,DIT> :: remove
|
||||
(
|
||||
CT client,
|
||||
const list <DIT> & r,
|
||||
list <DIT> & out
|
||||
)
|
||||
{
|
||||
ENTRY_LOG ();
|
||||
typename map < CT, list <DIT> > :: iterator dicIter =
|
||||
mDataItemsPerClientMap.find (client);
|
||||
if (dicIter != mDataItemsPerClientMap.end ()) {
|
||||
set_intersection (dicIter->second.begin (), dicIter->second.end (),
|
||||
r.begin (), r.end (),
|
||||
inserter (out,out.begin ()));
|
||||
if (!out.empty ()) {
|
||||
typename list <DIT> :: iterator it = out.begin ();
|
||||
for (; it != out.end (); ++it) {
|
||||
dicIter->second.erase (find (dicIter->second.begin (),
|
||||
dicIter->second.end (),
|
||||
*it));
|
||||
}
|
||||
}
|
||||
if (dicIter->second.empty ()) {
|
||||
mDataItemsPerClientMap.erase (dicIter);
|
||||
EXIT_LOG_WITH_ERROR ("%d",0);
|
||||
}
|
||||
}
|
||||
EXIT_LOG_WITH_ERROR ("%d",0);
|
||||
}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
void ClientIndex <CT,DIT> :: add
|
||||
(
|
||||
CT client,
|
||||
const list <DIT> & l,
|
||||
list <DIT> & out
|
||||
)
|
||||
{
|
||||
ENTRY_LOG ();
|
||||
list <DIT> difference;
|
||||
typename map < CT, list <DIT> > :: iterator dicIter =
|
||||
mDataItemsPerClientMap.find (client);
|
||||
if (dicIter != mDataItemsPerClientMap.end ()) {
|
||||
set_difference (l.begin (), l.end (),
|
||||
dicIter->second.begin (), dicIter->second.end (),
|
||||
inserter (difference,difference.begin ()));
|
||||
if (!difference.empty ()) {
|
||||
difference.sort ();
|
||||
out = difference;
|
||||
dicIter->second.merge (difference);
|
||||
dicIter->second.unique ();
|
||||
}
|
||||
} else {
|
||||
out = l;
|
||||
pair < CT, list <DIT> > dicnpair (client, out);
|
||||
mDataItemsPerClientMap.insert (dicnpair);
|
||||
}
|
||||
EXIT_LOG_WITH_ERROR ("%d",0);
|
||||
}
|
||||
|
||||
// Explicit instantiation must occur in same namespace where class is defined
|
||||
namespace loc_core
|
||||
{
|
||||
template class ClientIndex <IDataItemObserver *, DataItemId>;
|
||||
template class ClientIndex <string, DataItemId>;
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#ifndef __CLIENTINDEX_H__
|
||||
#define __CLIENTINDEX_H__
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <IClientIndex.h>
|
||||
|
||||
using loc_core::IClientIndex;
|
||||
|
||||
namespace loc_core
|
||||
{
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
|
||||
class ClientIndex : public IClientIndex <CT, DIT> {
|
||||
|
||||
public:
|
||||
|
||||
ClientIndex ();
|
||||
|
||||
~ClientIndex ();
|
||||
|
||||
bool isSubscribedClient (CT client);
|
||||
|
||||
void getSubscribedList (CT client, std :: list <DIT> & out);
|
||||
|
||||
int remove (CT client);
|
||||
|
||||
void remove (const std :: list <DIT> & r, std :: list <CT> & out);
|
||||
|
||||
void remove (CT client, const std :: list <DIT> & r, std :: list <DIT> & out);
|
||||
|
||||
void add (CT client, const std :: list <DIT> & l, std :: list <DIT> & out);
|
||||
|
||||
private:
|
||||
//Data members
|
||||
std :: map < CT , std :: list <DIT> > mDataItemsPerClientMap;
|
||||
};
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
#endif // #ifndef __CLIENTINDEX_H__
|
||||
@@ -1,202 +0,0 @@
|
||||
/* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <DataItemIndex.h>
|
||||
#include <platform_lib_log_util.h>
|
||||
#include <IDataItemObserver.h>
|
||||
#include <DataItemId.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace loc_core;
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
inline DataItemIndex <CT,DIT> :: DataItemIndex () {}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
inline DataItemIndex <CT,DIT> :: ~DataItemIndex () {}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
void DataItemIndex <CT,DIT> :: getListOfSubscribedClients
|
||||
(
|
||||
DIT id,
|
||||
list <CT> & out
|
||||
)
|
||||
{
|
||||
typename map < DIT, list <CT> > :: iterator cdiIter =
|
||||
mClientsPerDataItemMap.find (id);
|
||||
if (cdiIter != mClientsPerDataItemMap.end ()) {
|
||||
out = cdiIter->second;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
int DataItemIndex <CT,DIT> :: remove (DIT id) {
|
||||
int result = 0;
|
||||
ENTRY_LOG ();
|
||||
mClientsPerDataItemMap.erase (id);
|
||||
EXIT_LOG_WITH_ERROR ("%d",result);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
void DataItemIndex <CT,DIT> :: remove (const list <CT> & r, list <DIT> & out) {
|
||||
ENTRY_LOG ();
|
||||
typename map < DIT, list <CT> > :: iterator cdiIter =
|
||||
mClientsPerDataItemMap.begin ();
|
||||
while (cdiIter != mClientsPerDataItemMap.end()) {
|
||||
typename list <CT> :: const_iterator it = r.begin ();
|
||||
for (; it != r.end (); ++it) {
|
||||
typename list <CT> :: iterator iter =
|
||||
find
|
||||
(
|
||||
cdiIter->second.begin (),
|
||||
cdiIter->second.end (),
|
||||
*it
|
||||
);
|
||||
if (iter != cdiIter->second.end ()) {
|
||||
cdiIter->second.erase (iter);
|
||||
}
|
||||
}
|
||||
|
||||
if (cdiIter->second.empty ()) {
|
||||
out.push_back (cdiIter->first);
|
||||
// Post-increment operator increases the iterator but returns the
|
||||
// prevous one that will be invalidated by erase()
|
||||
mClientsPerDataItemMap.erase (cdiIter++);
|
||||
} else {
|
||||
++cdiIter;
|
||||
}
|
||||
}
|
||||
EXIT_LOG_WITH_ERROR ("%d",0);
|
||||
}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
void DataItemIndex <CT,DIT> :: remove
|
||||
(
|
||||
DIT id,
|
||||
const list <CT> & r,
|
||||
list <CT> & out
|
||||
)
|
||||
{
|
||||
ENTRY_LOG ();
|
||||
|
||||
typename map < DIT, list <CT> > :: iterator cdiIter =
|
||||
mClientsPerDataItemMap.find (id);
|
||||
if (cdiIter != mClientsPerDataItemMap.end ()) {
|
||||
set_intersection (cdiIter->second.begin (), cdiIter->second.end (),
|
||||
r.begin (), r.end (),
|
||||
inserter (out, out.begin ()));
|
||||
if (!out.empty ()) {
|
||||
typename list <CT> :: iterator it = out.begin ();
|
||||
for (; it != out.end (); ++it) {
|
||||
cdiIter->second.erase (find (cdiIter->second.begin (),
|
||||
cdiIter->second.end (),
|
||||
*it));
|
||||
}
|
||||
}
|
||||
if (cdiIter->second.empty ()) {
|
||||
mClientsPerDataItemMap.erase (cdiIter);
|
||||
EXIT_LOG_WITH_ERROR ("%d",0);
|
||||
}
|
||||
}
|
||||
EXIT_LOG_WITH_ERROR ("%d",0);
|
||||
}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
void DataItemIndex <CT,DIT> :: add
|
||||
(
|
||||
DIT id,
|
||||
const list <CT> & l,
|
||||
list <CT> & out
|
||||
)
|
||||
{
|
||||
ENTRY_LOG ();
|
||||
list <CT> difference;
|
||||
typename map < DIT, list <CT> > :: iterator cdiIter =
|
||||
mClientsPerDataItemMap.find (id);
|
||||
if (cdiIter != mClientsPerDataItemMap.end ()) {
|
||||
set_difference (l.begin (), l.end (),
|
||||
cdiIter->second.begin (), cdiIter->second.end (),
|
||||
inserter (difference, difference.begin ()));
|
||||
if (!difference.empty ()) {
|
||||
difference.sort ();
|
||||
out = difference;
|
||||
cdiIter->second.merge (difference);
|
||||
}
|
||||
} else {
|
||||
out = l;
|
||||
pair < DIT, list <CT> > cndipair (id, out);
|
||||
mClientsPerDataItemMap.insert (cndipair);
|
||||
}
|
||||
EXIT_LOG_WITH_ERROR ("%d",0);
|
||||
}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
void DataItemIndex <CT,DIT> :: add
|
||||
(
|
||||
CT client,
|
||||
const list <DIT> & l,
|
||||
list <DIT> & out
|
||||
)
|
||||
{
|
||||
ENTRY_LOG ();
|
||||
typename map < DIT, list <CT> > :: iterator cdiIter;
|
||||
typename list <DIT> :: const_iterator it = l.begin ();
|
||||
for (; it != l.end (); ++it) {
|
||||
cdiIter = mClientsPerDataItemMap.find (*it);
|
||||
if (cdiIter == mClientsPerDataItemMap.end ()) {
|
||||
out.push_back (*it);
|
||||
pair < DIT, list <CT> > cndiPair (*it, list <CT> (1, client));
|
||||
mClientsPerDataItemMap.insert (cndiPair);
|
||||
} else {
|
||||
typename list<CT> :: iterator clientIter =
|
||||
find
|
||||
(
|
||||
cdiIter->second.begin (),
|
||||
cdiIter->second.end (),
|
||||
client
|
||||
);
|
||||
if (clientIter == cdiIter->second.end()) {
|
||||
cdiIter->second.push_back (client);
|
||||
}
|
||||
}
|
||||
}
|
||||
EXIT_LOG_WITH_ERROR ("%d",0);
|
||||
}
|
||||
|
||||
// Explicit instantiation must occur in same namespace where class is defined
|
||||
namespace loc_core
|
||||
{
|
||||
template class DataItemIndex <IDataItemObserver *, DataItemId>;
|
||||
template class DataItemIndex <string, DataItemId>;
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __DATAITEMINDEX_H__
|
||||
#define __DATAITEMINDEX_H__
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <IDataItemIndex.h>
|
||||
|
||||
using loc_core::IDataItemIndex;
|
||||
|
||||
namespace loc_core
|
||||
{
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
|
||||
class DataItemIndex : public IDataItemIndex <CT, DIT> {
|
||||
|
||||
public:
|
||||
|
||||
DataItemIndex ();
|
||||
|
||||
~DataItemIndex ();
|
||||
|
||||
void getListOfSubscribedClients (DIT id, std :: list <CT> & out);
|
||||
|
||||
int remove (DIT id);
|
||||
|
||||
void remove (const std :: list <CT> & r, std :: list <DIT> & out);
|
||||
|
||||
void remove (DIT id, const std :: list <CT> & r, std :: list <CT> & out);
|
||||
|
||||
void add (DIT id, const std :: list <CT> & l, std :: list <CT> & out);
|
||||
|
||||
void add (CT client, const std :: list <DIT> & l, std :: list <DIT> & out);
|
||||
|
||||
private:
|
||||
std :: map < DIT, std :: list <CT> > mClientsPerDataItemMap;
|
||||
};
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
#endif // #ifndef __DATAITEMINDEX_H__
|
||||
@@ -1,83 +0,0 @@
|
||||
/* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __ICLIENTINDEX_H__
|
||||
#define __ICLIENTINDEX_H__
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace loc_core
|
||||
{
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
|
||||
class IClientIndex {
|
||||
public:
|
||||
|
||||
// Checks if client is subscribed
|
||||
virtual bool isSubscribedClient (CT client) = 0;
|
||||
|
||||
// gets subscription list
|
||||
virtual void getSubscribedList (CT client, std :: list <DIT> & out) = 0;
|
||||
|
||||
// removes an entry
|
||||
virtual int remove (CT client) = 0;
|
||||
|
||||
// removes std :: list of data items and returns a list of clients
|
||||
// removed if any.
|
||||
virtual void remove
|
||||
(
|
||||
const std :: list <DIT> & r,
|
||||
std :: list <CT> & out
|
||||
) = 0;
|
||||
|
||||
// removes list of data items indexed by client and returns list
|
||||
// of data items removed if any.
|
||||
virtual void remove
|
||||
(
|
||||
CT client,
|
||||
const std :: list <DIT> & r,
|
||||
std :: list <DIT> & out
|
||||
) = 0;
|
||||
|
||||
// adds/modifies entry in map and returns new data items added.
|
||||
virtual void add
|
||||
(
|
||||
CT client,
|
||||
const std :: list <DIT> & l,
|
||||
std :: list <DIT> & out
|
||||
) = 0;
|
||||
|
||||
// dtor
|
||||
virtual ~IClientIndex () {}
|
||||
};
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
#endif // #ifndef __ICLIENTINDEX_H__
|
||||
@@ -1,94 +0,0 @@
|
||||
/* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __IDATAITEMINDEX_H__
|
||||
#define __IDATAITEMINDEX_H__
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace loc_core
|
||||
{
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
|
||||
class IDataItemIndex {
|
||||
|
||||
public:
|
||||
|
||||
// gets std :: list of subscribed clients
|
||||
virtual void getListOfSubscribedClients
|
||||
(
|
||||
DIT id,
|
||||
std :: list <CT> & out
|
||||
) = 0;
|
||||
|
||||
// removes an entry from
|
||||
virtual int remove (DIT id) = 0;
|
||||
|
||||
// removes list of clients and returns a list of data items
|
||||
// removed if any.
|
||||
virtual void remove
|
||||
(
|
||||
const std :: list <CT> & r,
|
||||
std :: list <DIT> & out
|
||||
) = 0;
|
||||
|
||||
// removes list of clients indexed by data item and returns list of
|
||||
// clients removed if any.
|
||||
virtual void remove
|
||||
(
|
||||
DIT id,
|
||||
const std :: list <CT> & r,
|
||||
std :: list <CT> & out
|
||||
) = 0;
|
||||
|
||||
// adds/modifies entry and returns new clients added
|
||||
virtual void add
|
||||
(
|
||||
DIT id,
|
||||
const std :: list <CT> & l,
|
||||
std :: list <CT> & out
|
||||
) = 0;
|
||||
|
||||
// adds/modifies entry and returns yet to subscribe list of data items
|
||||
virtual void add
|
||||
(
|
||||
CT client,
|
||||
const std :: list <DIT> & l,
|
||||
std :: list <DIT> & out
|
||||
) = 0;
|
||||
|
||||
// dtor
|
||||
virtual ~IDataItemIndex () {}
|
||||
};
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
#endif // #ifndef __IDATAITEMINDEX_H__
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <IndexFactory.h>
|
||||
#include <IClientIndex.h>
|
||||
#include <ClientIndex.h>
|
||||
#include <IDataItemIndex.h>
|
||||
#include <DataItemIndex.h>
|
||||
#include <IDataItemObserver.h>
|
||||
#include <DataItemId.h>
|
||||
|
||||
using namespace std;
|
||||
using loc_core::IClientIndex;
|
||||
using loc_core::IDataItemIndex;
|
||||
using loc_core::IDataItemObserver;
|
||||
using namespace loc_core;
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
inline IClientIndex <CT, DIT> * IndexFactory <CT, DIT> :: createClientIndex
|
||||
()
|
||||
{
|
||||
return new (nothrow) ClientIndex <CT, DIT> ();
|
||||
}
|
||||
|
||||
template <typename CT, typename DIT>
|
||||
inline IDataItemIndex <CT, DIT> * IndexFactory <CT, DIT> :: createDataItemIndex
|
||||
()
|
||||
{
|
||||
return new (nothrow) DataItemIndex <CT, DIT> ();
|
||||
}
|
||||
|
||||
// Explicit instantiation must occur in same namespace where class is defined
|
||||
namespace loc_core
|
||||
{
|
||||
template class IndexFactory <IDataItemObserver *, DataItemId>;
|
||||
template class IndexFactory <string, DataItemId>;
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/* Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation, nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __INDEXFACTORY_H__
|
||||
#define __INDEXFACTORY_H__
|
||||
|
||||
#include <IClientIndex.h>
|
||||
#include <IDataItemIndex.h>
|
||||
|
||||
namespace loc_core
|
||||
{
|
||||
template <typename CT, typename DIT>
|
||||
class IndexFactory {
|
||||
|
||||
public:
|
||||
static IClientIndex <CT, DIT> * createClientIndex ();
|
||||
static IDataItemIndex <CT, DIT> * createDataItemIndex ();
|
||||
};
|
||||
|
||||
} // namespace loc_core
|
||||
|
||||
#endif // #ifndef __INDEXFACTORY_H__
|
||||
Reference in New Issue
Block a user