-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample.c
74 lines (62 loc) · 1.72 KB
/
sample.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* include */
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
// sampleClass.hをインクルードする
#include "sampleClass.h"
/* メソッド宣言 */
// メソッドの関数を宣言する
// staticでファイル内関数として宣言する
static void manager (sample_t *this);
static void setting (sample_t *this);
// インターフェースのメソッド
static void interfaceManager (interfaceSample_t *this);
static void interfaceInit (interfaceSample_t *this);
/* クラス初期値 */
// クラスの初期値を定義する
// constで定数として定義する
const sample_t sampleInitValue = {
// 属性
data_0,
0,
// 操作
&manager,
&setting,
};
// インターフェースの初期値
const interfaceSample_t interfaceSampleInitValue = {
&interfaceManager,
&interfaceInit,
};
/* メソッド定義 */
// メソッドの関数を定義する
static void manager (sample_t *this)
{
}
static void setting (sample_t *this)
{
}
// インターフェースのメソッド
static void interfaceManager (interfaceSample_t *this)
{
}
static void interfaceInit (interfaceSample_t *this)
{
}
/* コンストラクタ定義 */
// クラスの各メンバを初期値で初期化する
void sample_Constructor (sample_t *this)
{
// 属性
this->data = sampleInitValue.data;
this->value = sampleInitValue.value;
// 操作
this->pManager = sampleInitValue.pManager;
this->pSetting = sampleInitValue.pSetting;
// 集約
// 集約したクラスのコンストラクタを実行する
another_Constructor (&this->another);
// インターフェース
interfaceSample_Constructor (&this->interface, interfaceSampleInitValue);
}