您的位置:首页 > 其它

CM framework design and implementation

2010-12-15 18:10 323 查看

1CM in a nut shell

Nowadays along with the information blast, information managing requirement is much-needed. When to do, where to do and how to do content management is our consideration. We only focus on how to manage the content to provide convenient usage for outside client in this article.

2outer view of CM

From client side, get access to CM component easily as a thin client.
CM as a whole should be well designed. It should have a high security not to be corrupted by malicious source attack, large integrity with high level encapsulation that transparent to outer client by providing uniform interface, reusing ability for parsing strategy of diff source and extensibility and portability.

3inner view of CM



4improvement for future CM

Source manipulation:
l provide remote source registering , add verification mechanism for diff source entity.
l Add encrypt and decrypt processing ensure security of content transportation.
Filter policy:
l control the package size
Parsing and extraction:
l Add more robust error disposing mechanism to enhance stability or fault tolerance
l Support more package schema or format
l Design extraction policy for different medium using template
l Provide time out mechanism
Storage management:
l Design storage policy for different storage medium.
l Design indexer for processed content storage for fast access.
l Add concrete access control rule to restrict accessing entities’ rights or content-processing ability.
l Provide backup ability.
l Design content query template for content retrieving and manipulation.

Also focusing on our project CM within EAP, we have provided uniform interface, dynamic sensor of parser for diff source, what we lack of is more security for interface implementation check and portability of porting platform-independent dependency of CM to non-WinCE platform.

code snippet:

variant designed for encapsulating data which transfered between binary boundary.

//variant.h
#include "basic_type_def.h" //define UINT8 INT8...
#include "interface_base.h"
enum VariantType_t
{
VT_NULL,
VT_BOOL,
VT_UINT8,
VT_INT8,
//16,32,64
VT_FLOAT32,
VT_FLOAT64,
VT_CHAR,
VT_HANDLE,
VT_INTERFACE,
VT_BYTEARRAY,
VT_STRING,
VT_VARIANTARRAY,
VT_BUFFER,
};
//forward declar
class ByteArray;
class tagVariantArray ;
struct IInterfaceBase;
struct tagBuffer;

typedef struct tagVariant
{
enum VariantType_t type;
union
{
bool            boolVal;
UINT8           uint8Val;
INT8            int8Val;
FLOAT32         float32Val;
FLOAT64         float64Val;
CHAR            charVal;
HANDLE          handleVal;
IInterfaceBase* iPtr;
BtyeArray*      bArrayPtr;
String*         strPtr;
tagVariantArray VArrPtr;
tagBuffer*      bPtr;
};
}Variant_t;

typedef struct tagVariantArray
{
int32 count;
Variant_t elem[1];
Variant_t& operator[](size_t index){return elem[index];};
}VariantArrayHeader_t;

typedef struct tagBuffer
{
int32 size;
char  buf[1];
}BufferHeader_t;

template <typename TVarType>
struct varType_trait
{ static const VariantType_t value= NOT_VALID_TYPE_FOR_VARIANT;};
template <typename TVarType>
struct varType_trait <const TVarType>
{ static const VariantType_t value= varType_trait<TVarType>::value;};

#define VARTYPE_TRAIT(TYPE, VAL) /
template <> struct VarType_trait<TYPE>
{static const VariantType_t value = VAL;};
VARTYPE_TRAIT(bool, VT_BOOL)
VARTYPE_TRAIT(UINT8, VT_UINT8)
VARTYPE_TRAIT(INT8, VT_INT8)
VARTYPE_TRAIT(FLOAT32, VT_FLOAT32)
VARTYPE_TRAIT(FLOAT64, VT_FLOAT64)
VARTYPE_TRAIT(CHAR,    VT_CHAR)
VARTYPE_TRAIT(HANDLE,  VT_HANDLE)
VARTYPE_TRAIT(IInterfaceBase*, VT_INTERFACE)
VARTYPE_TRAIT(ByteArray*, VT_BTYEARRAY)
VARTYPE_TRAIT(String*, VT_STRING)
VARTYPE_TRAIT(tagVariantArray*, VT_VARIANTARRAY)
VARTYPE_TRAIT(tagBuffer*, VT_BUFFER)

template <VariantType_t Type>
struct var_trait
{typedef struct NOT_VALID_TYPE_FOR_VARIANT type;};

#define VAR_TRAIT_RW(VAL, TYPE, MEMBER, ISVALUE) /
template<> struct var_trait<VAL> /
{ /
typedef TYPE type; /
static const bool is_value = ISVALUE; /
static type r(const eapVariant_t* v) { return v->MEMBER; } /
static void r(const eapVariant_t* v, type& to) /
{ to = v->MEMBER; } /
static void w(Variant_t* v, type val) { v->MEMBER = val; } /
};

#define VAR_VALUE_TRAIT_RW(VAL, TYPE, MEMBER) VAR_TRAIT_RW(VAL, TYPE, MEMBER, true)
#define VAR_REF_TRAIT_RW(VAL, TYPE, MEMBER) VAR_TRAIT_RW(VAL, TYPE, MEMBER, false)

VAR_VALUE_TRAIT_RW(VT_BOOL,bool,boolVal)
VAR_VALUE_TRAIT_RW(VT_UINT8,UINT8,uint8Val)
...
VAR_REF_TRAIT_RW(VT_INTERFACE,IInterfaceBase*,iPtr)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: