749 lines
24 KiB
C++
749 lines
24 KiB
C++
/**
|
|
* @file include/ActivOneApi/FieldListValidator.h
|
|
*
|
|
* @brief Header file for the FieldListValidator class.
|
|
*/
|
|
|
|
#if (!defined ACTIV_ONE_API_FIELD_LIST_VALIDATOR_H)
|
|
#define ACTIV_ONE_API_FIELD_LIST_VALIDATOR_H
|
|
|
|
#include "ActivOneApi/External.h"
|
|
|
|
#include "ActivOneApi/TypeDefinitions.h"
|
|
#include "ActivOneApi/Constants/DataSourceIds.h"
|
|
#include "ActivOneApi/Constants/FieldIds.h"
|
|
#include "ActivOneApi/Detail/FieldListValidatorDetail.h"
|
|
|
|
#include "ActivMiddleware/ActivBase/FieldTypes/All.h"
|
|
|
|
//! Activ namespace.
|
|
namespace Activ
|
|
{
|
|
|
|
//! OneApi namespace.
|
|
namespace OneApi
|
|
{
|
|
|
|
// Forward declarations.
|
|
class FieldFilter;
|
|
class FieldListBuilder;
|
|
class RefreshMessage;
|
|
class SnapshotMessage;
|
|
class StreamMessage;
|
|
class UpdateMessage;
|
|
|
|
/**
|
|
* @brief FieldListValidator class.
|
|
*
|
|
* Note this class is not thread safe. Do not make concurrent calls to its methods from multiple threads.
|
|
*
|
|
* @tparam FIELD_STORAGE the underlying storage for fields. Currently available:
|
|
* OneApi::FlvTypes::SplitVectorFieldStorage - optimized for access speed at the expense of memory.
|
|
* OneApi::FlvTypes::HashFieldStorage - hash map storage for fields. Slower but more memory efficient.
|
|
*/
|
|
template<typename FIELD_STORAGE>
|
|
class FieldListValidatorT ACTIV_FINAL
|
|
{
|
|
public:
|
|
//! The storage type for this object.
|
|
typedef FIELD_STORAGE FieldStorage;
|
|
|
|
//! The Field iterator type.
|
|
typedef FlvDetail::ConstIterator ConstIterator;
|
|
|
|
//! The Field definition.
|
|
typedef FlvDetail::Field Field;
|
|
|
|
//! Constructor.
|
|
ACTIV_ONE_API FieldListValidatorT();
|
|
|
|
/**
|
|
* @brief Copy constructor.
|
|
*
|
|
* @param rhs a FieldListValidator to copy fields from.
|
|
*/
|
|
ACTIV_ONE_API explicit FieldListValidatorT(const FieldListValidatorT<OneApi::FlvTypes::FlatVectorFieldStorage> &rhs);
|
|
|
|
/**
|
|
* @brief Copy constructor.
|
|
*
|
|
* @param rhs a FieldListValidator to copy fields from.
|
|
*/
|
|
ACTIV_ONE_API explicit FieldListValidatorT(const FieldListValidatorT<OneApi::FlvTypes::HashFieldStorage> &rhs);
|
|
|
|
//! Destructor.
|
|
ACTIV_ONE_API ~FieldListValidatorT();
|
|
|
|
//! Get DataSourceId.
|
|
DataSourceId GetDataSourceId() const;
|
|
|
|
/**
|
|
* @brief Assignment operator. Performs a deep copy of rhs.
|
|
*
|
|
* @param rhs
|
|
*
|
|
* @return *this
|
|
*/
|
|
ACTIV_ONE_API FieldListValidatorT &operator=(const FieldListValidatorT &rhs);
|
|
|
|
/**
|
|
* @brief Assignment operator. Performs a deep copy of rhs.
|
|
*
|
|
* @tparam RHS_FIELD_STORAGE the FieldStorage used for rhs.
|
|
*
|
|
* @param rhs
|
|
*
|
|
* @return *this
|
|
*/
|
|
template<typename RHS_FIELD_STORAGE>
|
|
ACTIV_ONE_API FieldListValidatorT &operator=(const FieldListValidatorT<RHS_FIELD_STORAGE> &rhs);
|
|
|
|
/**
|
|
* @brief Reset.
|
|
*
|
|
* Resets the list of fields present in message.
|
|
*/
|
|
ACTIV_ONE_API void Reset();
|
|
|
|
/**
|
|
* @brief Clear.
|
|
*
|
|
* Resets the list of fields present in message and frees storage for all cached fields.
|
|
*/
|
|
ACTIV_ONE_API void Clear();
|
|
|
|
/**
|
|
* @brief Is a field present?
|
|
*
|
|
* @param fieldId
|
|
*
|
|
* @retval true if the field is present.
|
|
*/
|
|
bool IsFieldPresent(const FieldId fieldId) const;
|
|
|
|
/**
|
|
* @brief Is a field defined?
|
|
*
|
|
* @param fieldId
|
|
*
|
|
* @retval true if the field is present and defined.
|
|
*/
|
|
bool IsFieldDefined(const FieldId fieldId) const;
|
|
|
|
/**
|
|
* @brief Is empty?
|
|
*
|
|
* @retval true if empty.
|
|
*/
|
|
bool IsEmpty() const;
|
|
|
|
/**
|
|
* @brief Get the number of fields.
|
|
*
|
|
* @return The number of fields present.
|
|
*/
|
|
size_t GetNumberOfFields() const;
|
|
|
|
/**
|
|
* @brief Get a field.
|
|
*
|
|
* @param fieldId the field id.
|
|
* @param pField a pointer to the field.
|
|
*
|
|
* @retval STATUS_CODE_SUCCESS
|
|
* @retval STATUS_CODE_NOT_FOUND
|
|
*/
|
|
StatusCode GetField(const FieldId fieldId, const Field* &pField) const;
|
|
|
|
/**
|
|
* @brief Get ACTIV field type.
|
|
*
|
|
* @deprecated This method will be removed in future release.
|
|
*
|
|
* @param fieldId the field id.
|
|
* @param pFieldType reference to a pointer to a concrete ACTIV field type object.
|
|
*
|
|
* @retval STATUS_CODE_SUCCESS field is defined and pFieldType is set
|
|
* @retval STATUS_CODE_UNDEFINED field is undefined
|
|
* @retval STATUS_CODE_NOT_FOUND field not present
|
|
* @retval STATUS_CODE_INVALID_FIELD_TYPE template type T does not match the type of the field
|
|
*/
|
|
template<typename T>
|
|
StatusCode GetActivFieldType(const FieldId fieldId, const T* &pFieldType) const;
|
|
|
|
/**
|
|
* @brief Get ACTIV field type.
|
|
*
|
|
* @deprecated This method will be removed in future release.
|
|
*
|
|
* @param fieldId the field id.
|
|
*
|
|
* @return Const pointer to a concrete ACTIV field type object.
|
|
*
|
|
* @throw StatusCodeException, where m_errorCode is:
|
|
* STATUS_CODE_UNDEFINED field is undefined
|
|
* STATUS_CODE_NOT_FOUND field not present in record
|
|
* STATUS_CODE_INVALID_FIELD_TYPE template type @a T does not match the type of the field
|
|
*/
|
|
template<typename T>
|
|
const T *GetActivFieldType(const FieldId fieldId) const;
|
|
|
|
/**
|
|
* @brief Get field value base on ACTIV field.
|
|
*
|
|
* @tparam T concrete ACTIV field type.
|
|
*
|
|
* @param fieldId id of the field to get.
|
|
* @param pFieldValue reference to a pointer to a concrete ACTIV field type object.
|
|
*
|
|
* @retval STATUS_CODE_SUCCESS field is defined and pFieldValue is set
|
|
* @retval STATUS_CODE_NOT_FOUND field not present in record
|
|
* @retval STATUS_CODE_UNDEFINED_FIELD field is undefined
|
|
* @retval STATUS_CODE_INVALID_FIELD template type @a T does not match the type of the field
|
|
*/
|
|
template<typename T>
|
|
typename Boost::enable_if<IsFieldType<T>, StatusCode>::type
|
|
GetValue(const FieldId fieldId, const T* &pFieldValue) const;
|
|
|
|
/**
|
|
* @brief Get field value base on ACTIV field.
|
|
*
|
|
* @tparam T the ACTIV field type.
|
|
*
|
|
* @param fieldId id of the field to get.
|
|
* @param fieldValue reference to basic type.
|
|
*
|
|
* @retval STATUS_CODE_SUCCESS field is defined and fieldValue is set
|
|
* @retval STATUS_CODE_NOT_FOUND field not present in record
|
|
* @retval STATUS_CODE_UNDEFINED_FIELD field is undefined
|
|
* @retval STATUS_CODE_INVALID_FIELD template type @a T does not match the type of the field
|
|
* @retval STATUS_CODE_OUT_OF_RANGE template type @a T too short to store the value
|
|
*/
|
|
template<typename T>
|
|
typename Boost::enable_if_c<!IsFieldType<T>::value, StatusCode>::type
|
|
GetValue(const FieldId fieldId, T &fieldValue) const;
|
|
|
|
/**
|
|
* @brief Get a const reference to ACTIV type field value from the map.
|
|
*
|
|
* @tparam T concrete ACTIV field type.
|
|
*
|
|
* @param fieldId id of the field to get.
|
|
*
|
|
* @return field value of the defined field.
|
|
*
|
|
* @throw Exception
|
|
*/
|
|
template<typename T>
|
|
typename Boost::enable_if<IsFieldType<T>, const T&>::type
|
|
GetValue(const FieldId fieldId) const;
|
|
|
|
/**
|
|
* @brief Get a field value as basic type from the map.
|
|
*
|
|
* @tparam T the basic type (uint*_t, int*_t, bool, double, String, ...).
|
|
*
|
|
* @param fieldId id of the field to get.
|
|
*
|
|
* @return field value of the defined field.
|
|
*
|
|
* @throw Exception
|
|
*/
|
|
template<typename T>
|
|
typename Boost::enable_if_c<!IsFieldType<T>::value, T>::type
|
|
GetValue(const FieldId fieldId) const;
|
|
|
|
/**
|
|
* @brief Get an iterator to the first field in the message.
|
|
*
|
|
* @return an iterator object.
|
|
*/
|
|
ConstIterator begin() const;
|
|
|
|
/**
|
|
* @brief Get an iterator that points to beyond the last field in the message.
|
|
*
|
|
* @return an iterator object.
|
|
*/
|
|
ConstIterator end() const;
|
|
|
|
/**
|
|
* @brief Initialize.
|
|
*
|
|
* This call clears any fields currently in this object. New fields are then added from @a snapshotMessage.
|
|
*
|
|
* @param snapshotMessage reference to a SnapshotMessage object.
|
|
*
|
|
* @retval STATUS_CODE_SUCCESS
|
|
* @retval STATUS_CODE_INVALID_FORMAT
|
|
* @retval ...
|
|
*/
|
|
ACTIV_ONE_API StatusCode Initialize(const SnapshotMessage &snapshotMessage);
|
|
|
|
/**
|
|
* @brief Initialize.
|
|
*
|
|
* This call clears any fields currently in this object. New fields are then added from @a refreshMessage.
|
|
*
|
|
* @param refreshMessage reference to a RefreshMessage object.
|
|
*
|
|
* @retval STATUS_CODE_SUCCESS
|
|
* @retval STATUS_CODE_INVALID_FORMAT
|
|
* @retval ...
|
|
*/
|
|
ACTIV_ONE_API StatusCode Initialize(const RefreshMessage &refreshMessage);
|
|
|
|
/**
|
|
* @brief Initialize.
|
|
*
|
|
* This call clears any fields currently in this object. New fields are then added from @a refreshMessage if they exist in
|
|
* @a fieldFilter. If @a fieldFilter does not have any fields, then all new fields are added. Use the
|
|
* @see ApplyUpdateToExistingFieldsOnly method for any updates to preserve the filter.
|
|
*
|
|
* @param refreshMessage reference to a RefreshMessage object.
|
|
* @param fieldFilter the field filter.
|
|
*
|
|
* @retval STATUS_CODE_SUCCESS
|
|
* @retval STATUS_CODE_INVALID_FORMAT
|
|
* @retval ...
|
|
*/
|
|
ACTIV_ONE_API StatusCode Initialize(const RefreshMessage &refreshMessage, const FieldFilter &fieldFilter);
|
|
|
|
/**
|
|
* @brief Initialize.
|
|
*
|
|
* This call clears any fields currently in this object. New fields are then added from @a updateMessage.
|
|
*
|
|
* @param updateMessage reference to an UpdateMessage object.
|
|
*
|
|
* @retval STATUS_CODE_SUCCESS
|
|
* @retval STATUS_CODE_INVALID_FORMAT
|
|
* @retval ...
|
|
*/
|
|
ACTIV_ONE_API StatusCode Initialize(const UpdateMessage &updateMessage);
|
|
|
|
/**
|
|
* @brief Initialize.
|
|
*
|
|
* This call clears any fields currently in this object. New fields are then added from @a updateMessage if they exist in
|
|
* @a fieldFilter. If @a fieldFilter does not have any fields, then all new fields are added. Use the
|
|
* @see ApplyUpdateToExistingFieldsOnly method for any updates to preserve the filter.
|
|
*
|
|
* @param updateMessage reference to a UpdateMessage object.
|
|
* @param fieldFilter the field filter.
|
|
*
|
|
* @retval STATUS_CODE_SUCCESS
|
|
* @retval STATUS_CODE_INVALID_FORMAT
|
|
* @retval ...
|
|
*/
|
|
ACTIV_ONE_API StatusCode Initialize(const UpdateMessage &updateMessage, const FieldFilter &fieldFilter);
|
|
|
|
/**
|
|
* @brief Initialize.
|
|
*
|
|
* This call clears any fields currently in this object. New fields are then added from @a streamMessage.
|
|
*
|
|
* @param streamMessage reference to a StreamMessage object.
|
|
*
|
|
* @retval STATUS_CODE_SUCCESS
|
|
* @retval STATUS_CODE_INVALID_FORMAT
|
|
* @retval ...
|
|
*/
|
|
ACTIV_ONE_API StatusCode Initialize(const StreamMessage &streamMessage);
|
|
|
|
/**
|
|
* @brief Initialize.
|
|
*
|
|
* This call clears any fields currently in this object. New fields are then added from @a streamMessage.
|
|
*
|
|
* @param dataSourceId the DataSourceId of the field data in @a fieldListBuilder.
|
|
* @param fieldListBuilder reference to a FieldListBuilder object.
|
|
*
|
|
* @retval STATUS_CODE_SUCCESS
|
|
* @retval STATUS_CODE_INVALID_FORMAT
|
|
* @retval ...
|
|
*/
|
|
ACTIV_ONE_API StatusCode Initialize(const DataSourceId dataSourceId, const FieldListBuilder &fieldListBuilder);
|
|
|
|
/**
|
|
* @brief Initialize this with the fields from @a fieldListValidator
|
|
*
|
|
* This call clears any fields currently in this object. New fields are then added from @a fieldListValidator.
|
|
*
|
|
* @param fieldListValidator reference to an FieldListValidator object.
|
|
*
|
|
* @retval STATUS_CODE_SUCCESS
|
|
* @retval ...
|
|
*/
|
|
template<typename RHS_FIELD_STORAGE>
|
|
ACTIV_ONE_API StatusCode Initialize(const FieldListValidatorT<RHS_FIELD_STORAGE> &fieldListValidator);
|
|
|
|
/**
|
|
* @brief Apply fields to this.
|
|
*
|
|
* This call updates any existing fields add news fields from @ updateMessage. Pre-existing fields are not cleared.
|
|
* Note fields in @a updateMessage that have the rule RULE_DOES_NOT_UPDATE_LAST_VALUE will be ignored.
|
|
*
|
|
* @param updateMessage the updateMessage to apply.
|
|
*
|
|
* @retval STATUS_CODE_SUCCESS
|
|
* @retval STATUS_CODE_INVALID_FORMAT
|
|
* @retval STATUS_CODE_HEAP_EMPTY
|
|
* @retval ...
|
|
*/
|
|
ACTIV_ONE_API StatusCode ApplyUpdate(const UpdateMessage &updateMessage);
|
|
|
|
/**
|
|
* @brief Apply only the fields from an UpdateMessage to this that already exist in this.
|
|
*
|
|
* This call updates any existing fields from @ updateMessage. Pre-existing fields are not cleared.
|
|
* Note fields in @a updateMessage that have the rule RULE_DOES_NOT_UPDATE_LAST_VALUE will not be applied to this.
|
|
*
|
|
* @param updateMessage the updateMessage to apply.
|
|
*
|
|
* @retval STATUS_CODE_SUCCESS
|
|
* @retval STATUS_CODE_INVALID_FORMAT
|
|
* @retval STATUS_CODE_HEAP_EMPTY
|
|
* @retval ...
|
|
*/
|
|
ACTIV_ONE_API StatusCode ApplyUpdateToExistingFieldsOnly(const UpdateMessage &updateMessage);
|
|
|
|
/**
|
|
* @brief Apply all fields in another FieldListValidator to this.
|
|
*
|
|
* This call updates any existing fields add news fields from @ fieldListValidator. Pre-existing fields are not cleared.
|
|
* Note fields in @a fieldListValidator that have the rule RULE_DOES_NOT_UPDATE_LAST_VALUE will not be applied to this.
|
|
*
|
|
* @param fieldListValidator the fields to apply.
|
|
*
|
|
* @retval STATUS_CODE_SUCCESS
|
|
* @retval STATUS_CODE_INVALID_FORMAT
|
|
* @retval STATUS_CODE_HEAP_EMPTY
|
|
* @retval ...
|
|
*/
|
|
template<typename RHS_FIELD_STORAGE>
|
|
ACTIV_ONE_API StatusCode ApplyUpdate(const FieldListValidatorT<RHS_FIELD_STORAGE> &fieldListValidator);
|
|
|
|
/**
|
|
* @brief Apply only the fields from another FieldListValidator to this that already exist in this.
|
|
*
|
|
* This call updates any existing fields from @ fieldListValidator. Pre-existing fields are not cleared.
|
|
* Note fields in @a fieldListValidator that have the rule RULE_DOES_NOT_UPDATE_LAST_VALUE will not be applied to this.
|
|
*
|
|
* @param fieldListValidator the fields to apply.
|
|
*
|
|
* @retval STATUS_CODE_SUCCESS
|
|
* @retval STATUS_CODE_INVALID_FORMAT
|
|
* @retval STATUS_CODE_HEAP_EMPTY
|
|
* @retval ...
|
|
*/
|
|
template<typename RHS_FIELD_STORAGE>
|
|
ACTIV_ONE_API StatusCode ApplyUpdateToExistingFieldsOnly(const FieldListValidatorT<RHS_FIELD_STORAGE> &fieldListValidator);
|
|
|
|
/**
|
|
* @brief Set a field to a defined value.
|
|
*
|
|
* If the field already exists then its value will be updated.
|
|
*
|
|
* If the field does not exist it will be added.
|
|
*
|
|
* @param fieldId id of the field to set.
|
|
* @param fieldValue the field value to set.
|
|
* @param shouldUpdate does this field update the last cached value.
|
|
*
|
|
* @retval STATUS_CODE_SUCCESS
|
|
* @retval STATUS_CODE_NOT_INITIALIZED
|
|
* @retval ...
|
|
*/
|
|
ACTIV_ONE_API StatusCode SetField(const FieldId fieldId, const IFieldType &fieldValue, const bool shouldUpdate = true);
|
|
|
|
/**
|
|
* @brief Set a field to an undefined value.
|
|
*
|
|
* If the field already exists then its value will be updated.
|
|
*
|
|
* If the field does not exist it will be added.
|
|
*
|
|
* @param fieldId id of the field to set.
|
|
* @param shouldUpdate does this field update the last cached value.
|
|
*/
|
|
ACTIV_ONE_API void SetUndefinedField(const FieldId fieldId, const bool shouldUpdate = true);
|
|
|
|
/**
|
|
* @brief Return a string representation of the field contents.
|
|
*
|
|
* @return String representation of fields. Empty string if not initialized.
|
|
*/
|
|
ACTIV_ONE_API String ToString() const;
|
|
|
|
/**
|
|
* @brief Get the approximate memory usage of this object.
|
|
*
|
|
* Note this can be a slow operation.
|
|
*
|
|
* @return Approximate memory usage in bytes.
|
|
*/
|
|
ACTIV_ONE_API size_t GetMemoryUsage() const;
|
|
|
|
//! Sort the field list to provide consistent iteration ordering.
|
|
ACTIV_ONE_API void Sort();
|
|
|
|
private:
|
|
//! Get field storage.
|
|
FIELD_STORAGE &GetFieldStorage();
|
|
const FIELD_STORAGE &GetFieldStorage() const;
|
|
|
|
typedef FlvDetail::PresentFieldList PresentFieldList;
|
|
|
|
MessageValidator m_messageValidator; ///< To validate serialized data.
|
|
|
|
DataSourceId m_dataSourceId; ///< Data source for the current message.
|
|
|
|
PresentFieldList m_presentFieldList; ///< Vector of fields in message.
|
|
size_t m_numberOfFields;
|
|
|
|
FIELD_STORAGE m_fieldStorage;
|
|
|
|
template<typename RHS_FIELD_STORAGE>
|
|
friend class FieldListValidatorT;
|
|
friend class FieldListValidatorImpl;
|
|
friend class FieldListValidatorImplTemplateUpdate;
|
|
};
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
template<typename FIELD_STORAGE>
|
|
inline DataSourceId FieldListValidatorT<FIELD_STORAGE>::GetDataSourceId() const
|
|
{
|
|
return m_dataSourceId;
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
template<typename FIELD_STORAGE>
|
|
inline bool FieldListValidatorT<FIELD_STORAGE>::IsFieldPresent(const FieldId fieldId) const
|
|
{
|
|
return GetFieldStorage().IsFieldPresent(fieldId);
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
template<typename FIELD_STORAGE>
|
|
inline bool FieldListValidatorT<FIELD_STORAGE>::IsFieldDefined(const FieldId fieldId) const
|
|
{
|
|
return GetFieldStorage().IsFieldDefined(fieldId);
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
template<typename FIELD_STORAGE>
|
|
inline bool FieldListValidatorT<FIELD_STORAGE>::IsEmpty() const
|
|
{
|
|
return (0 == m_numberOfFields);
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
template<typename FIELD_STORAGE>
|
|
size_t FieldListValidatorT<FIELD_STORAGE>::GetNumberOfFields() const
|
|
{
|
|
return m_numberOfFields;
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
template<typename FIELD_STORAGE>
|
|
inline StatusCode FieldListValidatorT<FIELD_STORAGE>::GetField(const FieldId fieldId, const Field* &pField) const
|
|
{
|
|
if (!IsFieldPresent(fieldId))
|
|
return STATUS_CODE_NOT_FOUND;
|
|
|
|
const StatusCode statusCode = GetFieldStorage().GetField(fieldId, pField);
|
|
|
|
assert(!pField->IsDefined() || ((m_dataSourceId != DATA_SOURCE_PLATFORM) && (m_dataSourceId != DATA_SOURCE_LOCAL)) ||
|
|
(GetPlatformFieldType(fieldId) == FIELD_TYPE_UNKNOWN) || (GetPlatformFieldType(fieldId) == pField->GetType()));
|
|
|
|
return statusCode;
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
template<typename FIELD_STORAGE>
|
|
template<typename T>
|
|
inline StatusCode FieldListValidatorT<FIELD_STORAGE>::GetActivFieldType(const FieldId fieldId, const T* &pFieldType) const
|
|
{
|
|
assert(((m_dataSourceId != DATA_SOURCE_PLATFORM) && (m_dataSourceId != DATA_SOURCE_LOCAL)) ||
|
|
(GetPlatformFieldType(fieldId) == FIELD_TYPE_UNKNOWN) || (GetPlatformFieldType(fieldId) == T::FIELD_TYPE));
|
|
|
|
const Field *pField;
|
|
ACTIV_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, GetField(fieldId, pField));
|
|
|
|
return pField->GetActivFieldType(pFieldType);
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
template<typename FIELD_STORAGE>
|
|
template<typename T>
|
|
inline const T *FieldListValidatorT<FIELD_STORAGE>::GetActivFieldType(const FieldId fieldId) const
|
|
{
|
|
const T *pFieldType;
|
|
|
|
ACTIV_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, GetActivFieldType(fieldId, pFieldType));
|
|
|
|
return pFieldType;
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
template<typename FIELD_STORAGE>
|
|
template<typename T>
|
|
inline typename Boost::enable_if<IsFieldType<T>, StatusCode>::type
|
|
FieldListValidatorT<FIELD_STORAGE>::GetValue(const FieldId fieldId, const T* &pFieldValue) const
|
|
{
|
|
assert(((m_dataSourceId != DATA_SOURCE_PLATFORM) && (m_dataSourceId != DATA_SOURCE_LOCAL)) ||
|
|
(GetPlatformFieldType(fieldId) == FIELD_TYPE_UNKNOWN) || (GetPlatformFieldType(fieldId) == T::FIELD_TYPE));
|
|
|
|
const Field *pField;
|
|
ACTIV_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, GetField(fieldId, pField));
|
|
return pField->GetValue<T>(pFieldValue);
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
template<typename FIELD_STORAGE>
|
|
template<typename T>
|
|
inline typename Boost::enable_if_c<!IsFieldType<T>::value, StatusCode>::type
|
|
FieldListValidatorT<FIELD_STORAGE>::GetValue(const FieldId fieldId, T &fieldValue) const
|
|
{
|
|
const Field *pField;
|
|
ACTIV_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, GetField(fieldId, pField));
|
|
return pField->GetValue<T>(fieldValue);
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
template<typename FIELD_STORAGE>
|
|
template<typename T>
|
|
inline typename Boost::enable_if<IsFieldType<T>, const T&>::type
|
|
FieldListValidatorT<FIELD_STORAGE>::GetValue(const FieldId fieldId) const
|
|
{
|
|
const T *pFieldValue;
|
|
ACTIV_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, GetValue<T>(fieldId, pFieldValue));
|
|
return *pFieldValue;
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
template<typename FIELD_STORAGE>
|
|
template<typename T>
|
|
inline typename Boost::enable_if_c<!IsFieldType<T>::value, T>::type
|
|
FieldListValidatorT<FIELD_STORAGE>::GetValue(const FieldId fieldId) const
|
|
{
|
|
T fieldValue;
|
|
ACTIV_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, GetValue<T>(fieldId, fieldValue));
|
|
return fieldValue;
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
template<typename FIELD_STORAGE>
|
|
inline typename FieldListValidatorT<FIELD_STORAGE>::ConstIterator FieldListValidatorT<FIELD_STORAGE>::begin() const
|
|
{
|
|
return ConstIterator(m_presentFieldList.begin());
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
template<typename FIELD_STORAGE>
|
|
inline typename FieldListValidatorT<FIELD_STORAGE>::ConstIterator FieldListValidatorT<FIELD_STORAGE>::end() const
|
|
{
|
|
return ConstIterator(m_presentFieldList.end());
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
template<typename FIELD_STORAGE>
|
|
inline FIELD_STORAGE &FieldListValidatorT<FIELD_STORAGE>::GetFieldStorage()
|
|
{
|
|
return m_fieldStorage;
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
template<typename FIELD_STORAGE>
|
|
inline const FIELD_STORAGE &FieldListValidatorT<FIELD_STORAGE>::GetFieldStorage() const
|
|
{
|
|
return m_fieldStorage;
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
// For BOOST_FOREACH support, mainly.
|
|
template<typename FIELD_STORAGE>
|
|
inline FlvDetail::ConstIterator range_begin(const FieldListValidatorT<FIELD_STORAGE> &fieldListValidator)
|
|
{
|
|
return fieldListValidator.begin();
|
|
}
|
|
|
|
// For BOOST_FOREACH support, mainly.
|
|
template<typename FIELD_STORAGE>
|
|
inline FlvDetail::ConstIterator range_end(const FieldListValidatorT<FIELD_STORAGE> &fieldListValidator)
|
|
{
|
|
return fieldListValidator.end();
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
// Typedefs for FieldListValidator types.
|
|
|
|
//! FlatVectorFieldListValidator is optimized for speed efficiency at the expense of increase memory usage.
|
|
typedef FieldListValidatorT<OneApi::FlvTypes::FlatVectorFieldStorage> FlatVectorFieldListValidator;
|
|
|
|
//! HashFieldListValidator is optimized for memory efficiency at the expense of access speed.
|
|
typedef FieldListValidatorT<OneApi::FlvTypes::HashFieldStorage> HashFieldListValidator;
|
|
|
|
//! The default FieldListValidator definition.
|
|
typedef FlatVectorFieldListValidator FieldListValidator;
|
|
|
|
} // namespace OneApi
|
|
|
|
} // namespace Activ
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
namespace ACTIV_BOOST_NAMESPACE
|
|
{
|
|
|
|
// For BOOST_FOREACH support, mainly.
|
|
template<typename T>
|
|
struct range_const_iterator<Activ::OneApi::FieldListValidatorT<T> >
|
|
{
|
|
typedef typename Activ::OneApi::FlvDetail::ConstIterator type;
|
|
};
|
|
|
|
template<typename T>
|
|
struct range_mutable_iterator<Activ::OneApi::FieldListValidatorT<T> >
|
|
{
|
|
// There is no mutable iterator; use const.
|
|
typedef typename Activ::OneApi::FlvDetail::ConstIterator type;
|
|
};
|
|
|
|
namespace iterators
|
|
{
|
|
|
|
template<>
|
|
struct iterator_reference<Activ::OneApi::FlvDetail::ConstIterator>
|
|
{
|
|
typedef const Activ::OneApi::FlvDetail::Field &type;
|
|
};
|
|
|
|
} // namespace iterators
|
|
|
|
} // namespace ACTIV_BOOST_NAMESPACE
|
|
|
|
#endif // (!defined ACTIV_ONE_API_FIELD_LIST_VALIDATOR_H)
|