124 lines
4.1 KiB
C++
124 lines
4.1 KiB
C++
/**
|
|
* @file include/ActivMiddleware/ActivFramework/AmsDefinitions.h
|
|
*
|
|
* @brief Header file for ams constants, etc.
|
|
*/
|
|
|
|
#if (!defined ACTIV_FRAMEWORK_ROUTER_SERVICE_AMS_DEFINITIONS_H)
|
|
#define ACTIV_FRAMEWORK_ROUTER_SERVICE_AMS_DEFINITIONS_H
|
|
|
|
#include "ActivMiddleware/ActivFramework/External.h"
|
|
#include "ActivMiddleware/Misc/TemplateFunctions.h"
|
|
|
|
//! Activ namespace.
|
|
namespace Activ
|
|
{
|
|
|
|
//! Compression types.
|
|
#define ACTIV_AMS_COMPRESSION_TYPE_LIST(d) \
|
|
d(COMPRESSION_TYPE_NULL) \
|
|
d(COMPRESSION_TYPE_RDC) \
|
|
d(COMPRESSION_TYPE_ZLIB) \
|
|
d(COMPRESSION_TYPE_LZ4)
|
|
|
|
//! AmsDefinitions.
|
|
class AmsDefinitions
|
|
{
|
|
public:
|
|
//! Compression types.
|
|
enum CompressionType
|
|
{
|
|
ACTIV_AMS_COMPRESSION_TYPE_LIST(ACTIV_DECLARE_VALUE_WITH_COMMA)
|
|
NUM_COMPRESSION_TYPES, ///< Number of actual compression types.
|
|
COMPRESSION_TYPE_NONE = 200, ///< Value for uncompressed. Leaving room for new types to be added.
|
|
COMPRESSION_TYPE_ERROR ///< Error from compression layer.
|
|
};
|
|
|
|
//! Get RDC compression name, for rxCompression / txCompression options.
|
|
static const char *GetRdcCompressionString();
|
|
|
|
//! Get null compression name, for rxCompression / txCompression options.
|
|
static const char *GetNullCompressionString();
|
|
|
|
//! Get zlib compression name, for rxCompression / txCompression options.
|
|
static const char *GetZlibCompressionString();
|
|
|
|
//! Get lz4 compression name, for rxCompression / txCompression options.
|
|
static const char *GetLz4CompressionString();
|
|
|
|
//! Get none compression name, for rxCompression / txCompression options.
|
|
static const char *GetNoneCompressionString();
|
|
|
|
//! Get a string representation of a compression type.
|
|
static String CompressionTypeToString(const CompressionType compressionType);
|
|
|
|
//! Convert a string to a compression type.
|
|
static CompressionType StringToCompressionType(const String &str);
|
|
};
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline const char *AmsDefinitions::GetRdcCompressionString()
|
|
{
|
|
return "Rdc";
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline const char *AmsDefinitions::GetNullCompressionString()
|
|
{
|
|
return "Null";
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline const char *AmsDefinitions::GetZlibCompressionString()
|
|
{
|
|
return "Zlib";
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline const char *AmsDefinitions::GetLz4CompressionString()
|
|
{
|
|
return "Lz4";
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline const char *AmsDefinitions::GetNoneCompressionString()
|
|
{
|
|
return "None";
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline String AmsDefinitions::CompressionTypeToString(const CompressionType compressionType)
|
|
{
|
|
static const char * const strs[] = { ACTIV_AMS_COMPRESSION_TYPE_LIST(ACTIV_STRINGIZE_WITH_COMMA) };
|
|
|
|
return IndexToString(compressionType, strs, ACTIV_ARRAY_SIZE(strs));
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline AmsDefinitions::CompressionType AmsDefinitions::StringToCompressionType(const String &str)
|
|
{
|
|
if (0 == ::stricmp(str.c_str(), GetRdcCompressionString()))
|
|
return COMPRESSION_TYPE_RDC;
|
|
else if (0 == ::stricmp(str.c_str(), GetNullCompressionString()))
|
|
return COMPRESSION_TYPE_NULL;
|
|
else if (0 == ::stricmp(str.c_str(), GetZlibCompressionString()))
|
|
return COMPRESSION_TYPE_ZLIB;
|
|
else if (0 == ::stricmp(str.c_str(), GetLz4CompressionString()))
|
|
return COMPRESSION_TYPE_LZ4;
|
|
else if (0 == ::stricmp(str.c_str(), GetNoneCompressionString()))
|
|
return COMPRESSION_TYPE_NONE;
|
|
else
|
|
return COMPRESSION_TYPE_ERROR;
|
|
}
|
|
|
|
} // namespace Activ
|
|
|
|
#endif // (!defined ACTIV_FRAMEWORK_ROUTER_SERVICE_AMS_DEFINITIONS_H)
|