SRguide

Clunix Wiki
Yhkim (토론 | 기여) 사용자의 2014년 3월 18일 (화) 17:15 버전
(비교) ← 이전 판 | 현재 판 (비교) | 다음 판 → (비교)

목차

SR guide

이 문서는 SR에 대해 설명한다.

General

  • SR : Standard Representation의 약어이다.
  • 기본(Primitive) Type 지원: NULL, INT, LL, DBL, STR, OCT, DIR, PTR, BOOL
  • Aggregation Type: Enum(Bitwise 가능)
  • Extendable Type: 기본 타입을 확장하여 다양한 형 상속 가능하다
  • Complex Type: 트리 형식으로 표현 가능, Link를 통해 그래프도 가능하다

Feature

  • SR 생성, 삭제, 열람, 복사
  • ASR(Argumented SR): SR의 Human-readble 표현형
  • SR Encryption/Decryption

Visualized Structure

  • SR은 사람이 쉽게 읽을 수 있도록 아래와 같은 구조를 보여준다.
<dir> {
        ebc_port <int>10010;
        services <dir> {
                ebcd <dir> {
                        enabled <bool>true;
                        clname <str>ECMCluster;
                        ndname <str>node;
                        detection_interval <int>0;
                        bdcast_addr <str>"255.255.255.255";
                };
         };
};

SR Type

SR 타입은 위에서와 같이 다양하게 지원된다.

#define ST_NULL         0x000000
#define ST_INT          0x010000
#define ST_LL           0x020000
#define ST_DBL          0x030000
#define ST_STR          0x040000
#define ST_OCT          0x050000
#define ST_DIR          0x060000
#define ST_PTR          0x070000
#define ST_BOOL         0x080000

#define ST_APPLYOPT     0x010001
#define ST_LNP          0x060001
#define ST_LNI_TYPE     0x010002
#define ST_SRT          0x010003
#define ST_LNPSTR       0x040001

Create SR

SR을 만들때에는 아래와 같은 함수를 사용한다. libsr.h에서 확인할 수 있다.

sr_t *sr_create(srt_t srt);
sr_t *sr_create_ref(srt_t srt);
sr_t *sr_create_HMS(srt_t srt);
sr_t *sr_create_virtual(srt_t srt);
sr_t *sr_create_vHMS(srt_t srt);

#define sr_create_val(type, val)        sr_set_val(sr_create(type), val)
#define sr_create_int(type, ival)       sr_set_int(sr_create(type), ival)
#define sr_create_ll(type, lval)        sr_set_ll(sr_create(type), lval)
#define sr_create_dbl(type, dval)       sr_set_dbl(sr_create(type), dval)
#define sr_create_str(type, str)        sr_set_str(sr_create(type), str)
#define sr_create_oct(type, size, data) sr_set_oct(sr_create(type), size, data)
#define sr_create_ptr(type, ptr)        sr_set_ptr(sr_create(type), ptr)
#define sr_create_bool(type, bval)      sr_set_bool(sr_create(type), bval)
#define sr_create_dir()                 sr_create(ST_DIR)

/* create child */
#define sr_createc(root, name, type)    sr_setc(root, name, sr_create(type))
#define sr_createc_val(root, name, type, val)   \
        sr_setc(root, name, sr_create_val(type, val))
#define sr_createc_int(root, name, type, ival)  \
        sr_setc(root, name, sr_create_int(type, ival))
#define sr_createc_ll(root, name, type, lval)   \
        sr_setc(root, name, sr_create_ll(type, lval))
#define sr_createc_dbl(root, name, type, dval)  \
        sr_setc(root, name, sr_create_dbl(type, dval))
#define sr_createc_str(root, name, type, str)   \
        sr_setc(root, name, sr_create_str(type, str))
#define sr_createc_oct(root, name, type, size, data)   \
        sr_setc(root, name, sr_create_oct(type, size, data))
#define sr_createc_bool(root, name, type, bval)   \
        sr_setc(root, name, sr_create_bool(type, bval))
#define sr_createc_dir(root, name) \
        sr_setc(root, name, sr_create_dir())
#define sr_createc_bool(root, name, type, bval)  \
        sr_setc(root, name, sr_create_bool(type, bval))
#define sr_createc_ptr(root, name, type, ptr)   \
        sr_setc(root, name, sr_create_ptr(type, ptr))
#define sr_createc_ref(root, name, type, sr_LNP)        \
        sr_set_ref(sr_setc(root, name, sr_create_ref(type)), sr_LNP)
#define sr_createc_HMS(root, name, type)  sr_setc(root, name, sr_create_HMS(type))


/* create indexed child */
#define sr_createi(dir, idx, type) \
                sr_set_child_idx(dir, idx, sr_create(type))
#define sr_createi_val(dir, idx, type, val) \
                sr_set_idx(dir, idx, sr_create_val(type, val))
#define sr_createi_int(dir, idx, type, ival) \
                sr_set_idx(dir, idx, sr_create_int(type, ival))
#define sr_createi_ll(dir, idx, type, lval) \
                sr_set_idx(dir, idx, sr_create_ll(type, lval))
#define sr_createi_dbl(dir, idx, type, dval) \
                sr_set_idx(dir, idx, sr_create_dbl(type, dval))
#define sr_createi_str(dir, idx, type, str) \
                sr_set_idx(dir, idx, sr_create_str(type, str))
#define sr_createi_oct(dir, idx, type, size, data) \
                sr_set_idx(dir, idx, sr_create_oct(type, size, data))
#define sr_createi_dir(dir, idx) \
                sr_set_idx(dir, idx, sr_create_dir())


/* create descendant */
#define sr_createn1(root, LNP, type)    sr_setn1(root, LNP, sr_create(type))
#define sr_createn1_val(root, LNP, type, val)   \
  sr_setn1(root, LNP, sr_create_val(type, val))
#define sr_createn1_int(root, LNP, type, ival)  \
  sr_setn1(root, LNP, sr_create_int(type, ival))
#define sr_createn1_ll(root, LNP, type, lval)   \
  sr_setn1(root, LNP, sr_create_ll(type, lval))
#define sr_createn1_dbl(root, LNP, type, dval)  \
  sr_setn1(root, LNP, sr_create_dbl(type, dval))
#define sr_createn1_str(root, LNP, type, str)   \
  sr_setn1(root, LNP, sr_create_str(type, str))
#define sr_createn1_oct(root, LNP, type, size, data)   \
  sr_setn1(root, LNP, sr_create_oct(type, size, data))
#define sr_createn1_dir(root, LNP)  sr_setn1(root, LNP, sr_create_dir())
#define sr_createn1_bool(root, LNP, type, bval)  \
        sr_setn1(root, LNP, sr_create_bool(type, bval))
#define sr_createn1_ptr(root, LNP, type, ptr)  \
        sr_setn1(root, LNP, sr_create_ptr(type, ptr))
#define sr_createn1_ref(root, LNP, type, target)  \
        sr_set_ref(sr_setn1(root, LNP, sr_create_ref(type)), target)
#define sr_createn1_HMS(root, LNP, type)  sr_setn1(root, LNP, sr_create_HMS(type))
  • 간단한 사용법은 EBCguide 를 참고하면 된다.
부서별 위키