chapter 04-01

資料的存取 (內部模組)

內部模組存取資料庫的時機點有二個.


一是在 #03-01# 中 [從系統中取出資料] 的情況, 這時候 mcm_daemon 的處理步驟 :
A01.  外部程式取得使用權.
A02.  外部程式呼叫內部模組處理要取得的資料.
A03.  內部模組處理要取得的資料並放到資料庫中.
A04.  外部程式取得資料.
A05.  外部程式釋放使用權.


二是在 #03-01# 中 [操控系統] 的情況, 這時候 mcm_daemon 的處理步驟 :
B01.  外部程式取得使用權.
B02.  外部程式修改資料 (設定/增加/刪除).
B03.  mcm_daemon 根據不同的修改方式處理資料.
設定: 將設定的資料放到資料庫的新進資料區, 並標註資料被設定. (原始的資料放在系統資料區)
增加: 在資料庫增加紀錄, 並將增加的資料放到新進資料區, 並標註資料被增加.
刪除: 標註資料被刪除. (原始的資料放在系統資料區)
B04.  外部程式呼叫內部模組處理修改的資料.
B05.  外部程式釋放使用權.
B06.  mcm_daemon 根據最後一次的執行結果決定如何處理修改的資料.
成功: 將所做的修改套用回資料庫.
失敗: 放棄所做的修改.


此章節是說明在 [A03] [B04] 的內部模組要如何存取資料庫.


模組程式的格式

內部模組必須放在 mint_cm/cm_daemon/mcm_module
沒有限制函式的放置方式, 可以依據不同的功能將各種函式分類放在不同的檔案.

需要的標頭檔 :
#include "mcm_lib/mcm_lheader/mcm_type.h"
#include "mcm_lib/mcm_lheader/mcm_size.h"
#include "mcm_lib/mcm_lheader/mcm_control.h"
#include "mcm_lib/mcm_lheader/mcm_connect.h"
#include "mcm_lib/mcm_lheader/mcm_return.h"
#include "mcm_lib/mcm_lheader/mcm_debug.h"
#include "mcm_lib/mcm_lheader/mcm_data_exinfo_auto.h"
#include "../mcm_service_handle_define.h"
#include "../mcm_config_handle_extern.h"


函式格式 :
int <function_name>(struct mcm_service_session_t *this_session)


範例 :
int system_config(struct mcm_service_session_t *this_session)
{
    ...
}