Commit dc964c35 authored by pooja's avatar pooja Committed by Ashok Babu Channa

Add doxygen comments for simulator

Change-Id: Icd198cf5bd0ddae84bd6fa29757e6302cded9227
Signed-off-by: default avatarpooja <pooja.k@partner.samsung.com>
parent 1c13700f
......@@ -26,34 +26,39 @@
#include <memory>
#include "simulator_error_codes.h"
/** enum for observe type value */
enum class ObserveType
{
OBSERVE,
OBSERVE_ALL
};
/** enum value for request type value */
enum class RequestType
{
RQ_TYPE_UNKNOWN,
RQ_TYPE_GET,
RQ_TYPE_PUT,
RQ_TYPE_POST,
RQ_TYPE_DELETE
RQ_TYPE_UNKNOWN, /**< unknown type request */
RQ_TYPE_GET, /**< get type request */
RQ_TYPE_PUT, /**< put type request */
RQ_TYPE_POST, /**< post type request */
RQ_TYPE_DELETE /**< delete type request */
};
/** structure for validation status */
typedef struct
{
bool isVerified;
SimulatorResult errorCode;
bool isVerified; /**< verified state value */
SimulatorResult errorCode; /**< simulator result */
} ValidationStatus;
/** enum for operation state value */
typedef enum
{
OP_START,
OP_COMPLETE,
OP_ABORT
OP_START, /**< start operation */
OP_COMPLETE, /**< complete operation */
OP_ABORT /**< abort the operation */
} OperationState;
/** enum for connectivity type value */
typedef enum
{
/** use when defaults are ok. */
......
......@@ -26,64 +26,64 @@
typedef enum
{
/** STACK error codes - START */
SIMULATOR_OK = 0,
SIMULATOR_RESOURCE_CREATED,
SIMULATOR_RESOURCE_DELETED,
SIMULATOR_CONTINUE,
SIMULATOR_RESOURCE_CHANGED,
SIMULATOR_INVALID_URI = 20,
SIMULATOR_INVALID_QUERY,
SIMULATOR_INVALID_IP,
SIMULATOR_INVALID_PORT,
SIMULATOR_INVALID_CALLBACK,
SIMULATOR_INVALID_METHOD,
SIMULATOR_INVALID_PARAM,
SIMULATOR_INVALID_OBSERVE_PARAM,
SIMULATOR_NO_MEMORY,
SIMULATOR_COMM_ERROR,
SIMULATOR_TIMEOUT,
SIMULATOR_ADAPTER_NOT_ENABLED,
SIMULATOR_NOTIMPL,
SIMULATOR_NO_RESOURCE,
SIMULATOR_RESOURCE_ERROR,
SIMULATOR_SLOW_RESOURCE,
SIMULATOR_DUPLICATE_REQUEST,
SIMULATOR_NO_OBSERVERS,
SIMULATOR_OBSERVER_NOT_FOUND,
SIMULATOR_VIRTUAL_DO_NOT_HANDLE,
SIMULATOR_INVALID_OPTION,
SIMULATOR_MALFORMED_RESPONSE,
SIMULATOR_PERSISTENT_BUFFER_REQUIRED,
SIMULATOR_INVALID_REQUEST_HANDLE,
SIMULATOR_INVALID_DEVICE_INFO,
SIMULATOR_INVALID_JSON,
SIMULATOR_UNAUTHORIZED_REQ,
SIMULATOR_TOO_LARGE_REQ,
SIMULATOR_PDM_IS_NOT_INITIALIZED,
SIMULATOR_DUPLICATE_UUID,
SIMULATOR_INCONSISTENT_DB,
SIMULATOR_AUTHENTICATION_FAILURE,
SIMULATOR_OK = 0, /**< Success */
SIMULATOR_RESOURCE_CREATED, /**< Resource created */
SIMULATOR_RESOURCE_DELETED, /**< Resource deleted */
SIMULATOR_CONTINUE, /**< Continue */
SIMULATOR_RESOURCE_CHANGED, /**< Resource changed */
SIMULATOR_INVALID_URI = 20, /**< Invalid URI */
SIMULATOR_INVALID_QUERY, /**< Invalid query */
SIMULATOR_INVALID_IP, /**< Invalid IP */
SIMULATOR_INVALID_PORT, /**< Invalid port */
SIMULATOR_INVALID_CALLBACK, /**< Invalid callback */
SIMULATOR_INVALID_METHOD, /**< Invalid method */
SIMULATOR_INVALID_PARAM, /**< Invalid parameter */
SIMULATOR_INVALID_OBSERVE_PARAM, /**< Invalid observe parameter */
SIMULATOR_NO_MEMORY, /**< No memory */
SIMULATOR_COMM_ERROR, /**< Comm error */
SIMULATOR_TIMEOUT, /**< Timeout */
SIMULATOR_ADAPTER_NOT_ENABLED, /**< Adapter not enabled */
SIMULATOR_NOTIMPL, /**< Not impl */
SIMULATOR_NO_RESOURCE, /**< No resource */
SIMULATOR_RESOURCE_ERROR, /**< Resource error */
SIMULATOR_SLOW_RESOURCE, /**< Slow resource */
SIMULATOR_DUPLICATE_REQUEST, /**< Duplicate request */
SIMULATOR_NO_OBSERVERS, /**< No observers */
SIMULATOR_OBSERVER_NOT_FOUND, /**< Observer not found */
SIMULATOR_VIRTUAL_DO_NOT_HANDLE, /**< Virtual do not handle */
SIMULATOR_INVALID_OPTION, /**< Invalid option */
SIMULATOR_MALFORMED_RESPONSE, /**< Malformed response */
SIMULATOR_PERSISTENT_BUFFER_REQUIRED, /**< Persistent buffer required */
SIMULATOR_INVALID_REQUEST_HANDLE, /**< Invalid request handle */
SIMULATOR_INVALID_DEVICE_INFO, /**< Invalid device information */
SIMULATOR_INVALID_JSON, /**< Invalid json */
SIMULATOR_UNAUTHORIZED_REQ, /**< Unauthorized request */
SIMULATOR_TOO_LARGE_REQ, /**< Large request */
SIMULATOR_PDM_IS_NOT_INITIALIZED, /**< PDM is not initialized */
SIMULATOR_DUPLICATE_UUID, /**< Duplicate UUID */
SIMULATOR_INCONSISTENT_DB, /**< Inconsistent DB */
SIMULATOR_AUTHENTICATION_FAILURE, /**< Authentication failure */
#ifdef WITH_PRESENCE
SIMULATOR_PRESENCE_STOPPED = 128,
SIMULATOR_PRESENCE_TIMEOUT,
SIMULATOR_PRESENCE_DO_NOT_HANDLE,
SIMULATOR_PRESENCE_STOPPED = 128, /**< Presence stopped */
SIMULATOR_PRESENCE_TIMEOUT, /**< Presence timeout */
SIMULATOR_PRESENCE_DO_NOT_HANDLE, /**< Presence do not handle */
#endif
/** STACK error codes - END */
/** Simulator specific error codes - START */
SIMULATOR_INVALID_TYPE,
SIMULATOR_NOT_SUPPORTED,
SIMULATOR_OPERATION_NOT_ALLOWED,
SIMULATOR_OPERATION_IN_PROGRESS,
SIMULATOR_INVALID_TYPE, /**< Invalid type */
SIMULATOR_NOT_SUPPORTED, /**< Not supported */
SIMULATOR_OPERATION_NOT_ALLOWED, /**< Operation not allowed */
SIMULATOR_OPERATION_IN_PROGRESS, /**< Operation in progress */
SIMULATOR_INVALID_RESPONSE_CODE,
SIMULATOR_UKNOWN_PROPERTY,
SIMULATOR_TYPE_MISMATCH,
SIMULATOR_BAD_VALUE,
SIMULATOR_BAD_OBJECT,
SIMULATOR_BAD_SCHEMA,
SIMULATOR_INVALID_RESPONSE_CODE, /**< Invalid response code */
SIMULATOR_UKNOWN_PROPERTY, /**< Unknown property */
SIMULATOR_TYPE_MISMATCH, /**< Type mismatch */
SIMULATOR_BAD_VALUE, /**< Bad value */
SIMULATOR_BAD_OBJECT, /**< Bad object */
SIMULATOR_BAD_SCHEMA, /**< Bad schema */
/** Simulator specific error codes - END */
SIMULATOR_ERROR = 255
SIMULATOR_ERROR = 255 /**< Error */
} SimulatorResult;
#endif //SIMULATOR_ERROR_CODES_H_
\ No newline at end of file
#endif //SIMULATOR_ERROR_CODES_H_
......@@ -30,17 +30,26 @@
#include <iostream>
#include <memory>
/**
* @class ILogger
*/
class ILogger
{
public:
enum Level
{
INFO = 0,
DEBUG,
WARNING,
ERROR
INFO = 0, /**< information level log message */
DEBUG, /**< debug level log message */
WARNING, /**< warning level log message */
ERROR /**< error level log message */
};
/**
* get the string value according to the level value
* @param[in] level log level value
*
* @return string message
*/
static const char *getString(Level level)
{
switch (level)
......@@ -56,12 +65,33 @@ class ILogger
virtual void write(std::string, Level, std::string) = 0;
};
/**
* @class Logger
*/
class Logger
{
public:
/**
* set the log target to console
* @return true or false
*/
bool setDefaultConsoleTarget();
/**
* set the log target to file
* @param[in] path file path
* @return true or false
*/
bool setDefaultFileTarget(const std::string &path);
/**
* set the log to custom target
* @param[in] target log target
*/
void setCustomTarget(const std::shared_ptr<ILogger> &target);
/**
* write the log to given target
* @param[in] level type of log
* @param[in] str oc string stream
*/
void write(ILogger::Level level, std::ostringstream &str);
private:
......@@ -76,4 +106,4 @@ auto simLogger() -> Logger &;
}
#endif
#endif
\ No newline at end of file
#endif
......@@ -107,16 +107,81 @@ class PlatformInfo
*/
std::string getSystemTime() const;
/**
* This method is for set the platform ID
*
* @param platformId platform identity
*/
void setPlatformID(const std::string &platformId);
/**
* This method is for set the platform version
*
* @param platformVersion platform version information
*/
void setPlatformVersion(const std::string &platformVersion);
/**
* This method is for set the manufacturer name
*
* @param manufacturerName detail of manufacturer name
*/
void setManufacturerName(const std::string &manufacturerName);
/**
* This method is for set the manufacturer URL details
*
* @param manufacturerUrl manufacturer URL detail to set
*/
void setManufacturerUrl(const std::string &manufacturerUrl);
/**
* This method is for set model number
*
* @param modelNumber model number information
*/
void setModelNumber(const std::string &modelNumber);
/**
* This method is for set date of manufacture
*
* @param dateOfManufacture date of manufacture to set
*/
void setDateOfManfacture(const std::string &dateOfManufacture);
/**
* This method is for set the OS version
*
* @param osVersion OS version information to set
*/
void setOSVersion(const std::string &osVersion);
/**
* This method is for set the hardware version
*
* @param hwVersion hardware version information to set
*/
void setHardwareVersion(const std::string &hwVersion);
/**
* This method is for set the firmware version information
*
* @param firmwareVersion firmware version to set
*/
void setFirmwareVersion(const std::string &firmwareVersion);
/**
* This method is for set the support URL detail
*
* @param supportUrl support URL to set
*/
void setSupportUrl(const std::string &supportUrl);
/**
* This method is for set the system time information
*
* @param systemTime system time to set
*/
void setSystemTime(const std::string &systemTime);
private:
......
......@@ -24,17 +24,40 @@
#include "simulator_client_types.h"
#include "simulator_resource_model_schema.h"
/**
* @class SimulatorRequestModel
*/
class SimulatorRequestModel
{
public:
SimulatorRequestModel();
SimulatorRequestModel(RequestType type);
/**
* Get the request type of topic
* @return request type
*/
RequestType getType() const;
/**
* Get the query parameters
* @return parameters
*/
std::map<std::string, std::vector<std::string>> getQueryParams() const;
/**
* Get the request body schema
* @return schema information
*/
std::shared_ptr<SimulatorResourceModelSchema> getRequestBodySchema() const;
/**
* Set the query parameters
* @param[in] queryParams parameter to set
*/
void setQueryParams(const std::map<std::string, std::vector<std::string>> &queryParams);
/**
* Set the request body schema
* @param[in] repSchema schema to set
*/
void setRequestBodySchema(const std::shared_ptr<SimulatorResourceModelSchema> &repSchema);
private:
......
......@@ -62,13 +62,13 @@ std::vector<std::vector<std::vector<SimulatorResourceModel>>>
enum class AttributeValueType
{
UNKNOWN,
INTEGER,
DOUBLE,
BOOLEAN,
STRING,
RESOURCE_MODEL,
VECTOR
UNKNOWN, /**< unknown value type */
INTEGER, /**< integer value type */
DOUBLE, /**< double value type */
BOOLEAN, /**< boolean value type */
STRING, /**< string value type */
RESOURCE_MODEL, /**< resource model type */
VECTOR /**< vector type */
};
class OCRepresentationBuilder;
......@@ -101,6 +101,12 @@ class SimulatorResourceModel
int m_depth;
};
/**
* add the value
* @param[in] name find the name
* @param[in] value add the attribute value for the given name
* @return boolean value
*/
template <typename T>
bool add(const std::string &name, T value)
{
......@@ -113,6 +119,11 @@ class SimulatorResourceModel
return false;
}
/**
* get the value
* @param[in] name get the value for given name
* @return value
*/
template <typename T>
T get(const std::string &name) const
{
......@@ -132,6 +143,12 @@ class SimulatorResourceModel
return val;
}
/**
* update the value
* @param[in] name name to find
* @param[in] value update the value
* @return boolean value
*/
template <typename T>
bool update(const std::string &name, T value)
{
......@@ -139,16 +156,35 @@ class SimulatorResourceModel
return updateValue(name, newValue);
}
/**
* remove the value
* @param[in] name name to remove
* @return boolean value
*/
bool remove(const std::string &name);
bool contains(const std::string &name) const;
size_t size() const;
/**
* get the type
* @param[in] name get the type of given name
* @return type of name
*/
TypeInfo getType(const std::string &name) const;
/**
* get attribute values
* @return attribute value
*/
std::map<std::string, AttributeValueVariant> getAttributeValues() const;
/**
* get attribute values using name value
* @param name attribute name
* @return attribute value
*/
AttributeValueVariant getAttributeValue(const std::string &name) const;
std::set<std::string> getAttributeNameSet() const;
......@@ -166,6 +202,9 @@ class SimulatorResourceModel
std::map<std::string, AttributeValueVariant> m_attributes;
};
/**
* @class SimulatorResourceAttribute
*/
class SimulatorResourceAttribute
{
public:
......@@ -173,14 +212,42 @@ class SimulatorResourceAttribute
SimulatorResourceAttribute(const std::string &name);
SimulatorResourceAttribute(const std::string &name, const AttributeValueVariant &value);
/**
* get the resource name
* @return resource name
*/
std::string getName() const;
/**
* get the type
* @return resource type
*/
const SimulatorResourceModel::TypeInfo getType() const;
/**
* get the attribute property
* @return attribute property
*/
std::shared_ptr<AttributeProperty> getProperty() const;
/**
* get the attribute value
* @return attribute value
*/
AttributeValueVariant getValue() const;
/**
* set the atribute name
* @param[in] name set the name
*/
void setName(const std::string &name);
/**
* set the attribute property
* @param[in] property property to set
*/
void setProperty(const std::shared_ptr<AttributeProperty> &property);
/**
* set attribute value
* @param[in] value value to set
*/
template <typename T>
void setValue(const T &value)
{
......
......@@ -37,102 +37,214 @@ class AttributeProperty
public:
enum class Type
{
INTEGER,
DOUBLE,
BOOLEAN,
STRING,
MODEL,
ARRAY
INTEGER, /**< Integer type */
DOUBLE, /**< Double type */
BOOLEAN, /**< Boolean type */
STRING, /**< String type */
MODEL, /**< Model type */
ARRAY /**< Array type */
};
explicit AttributeProperty(Type type);
virtual ~AttributeProperty() {}
/**
* get the attribute type
* @return attribute type
*/
Type getType() const;
/**
* Check the integer value
* @return boolean value
*/
virtual bool isInteger() const
{
return false;
}
/**
* Check the double value
* @return boolean value
*/
virtual bool isDouble() const
{
return false;
}
/**
* Check the boolean value
* @return boolean value
*/
virtual bool isBoolean() const
{
return false;
}
/**
* Check the string value
* @return boolean value
*/
virtual bool isString() const
{
return false;
}
/**
* Check array
* @return boolean value
*/
virtual bool isArray() const
{
return false;
}
/**
* Check model
* @return boolean value
*/
virtual bool isModel() const
{
return false;
}
/**
* Integer property
* @return integer property object
*/
virtual std::shared_ptr<IntegerProperty> asInteger()
{
return nullptr;
}
/**
* double property
* @return double property object
*/
virtual std::shared_ptr<DoubleProperty> asDouble()
{
return nullptr;
}
/**
* boolean property
* @return boolean property object
*/
virtual std::shared_ptr<BooleanProperty> asBoolean()
{
return nullptr;
}
/**
* string property
* @return string property object
*/
virtual std::shared_ptr<StringProperty> asString()
{
return nullptr;
}
/**
* array property
* @return array property object
*/