@@ -37,72 +37,18 @@ cmake -S . -B build -DCMAKE_INSTALL_PREFIX="./output" -DCMAKE_PREFIX_PATH="./out
37
37
cmake --build build -j --config Release --target install
38
38
```
39
39
40
- ### Hello,World 示例
41
- ``` c
42
- #include < string.h>
43
- #include < iostream>
40
+ ### Hello,World API示例
41
+ - [ API 示例] ( test/hello_test.cpp )
44
42
45
- #include " myframe/msg.h"
46
- #include " myframe/actor.h"
47
-
48
- using namespace myframe;
49
- /*
50
- 该actor实现:
51
- 自己给自己发送一条消息
52
- */
53
- class Demo : public Actor
54
- {
55
- public:
56
- /* actor模块加载完毕后调用 * /
57
- int Init(const char* param) override {
58
- /* 构造 hello,world 消息发送给自己 * /
59
- auto mailbox = GetMailbox();
60
- mailbox->Send("actor.demo.echo_hello_world", std::make_shared<Msg >("hello,world"));
61
- }
62
-
63
- void Proc(const std::shared_ptr<const Msg >& msg) override {
64
- /* 获得文本消息, 打印 源actor地址 目的actor地址 消息内容 * /
65
- std::cout << * msg << ": " << msg->GetData() << std::endl;
66
- }
67
- };
68
-
69
- /* 框架根据描述文件创建actor实例函数 */
70
- extern " C" std::shared_ptr<Actor> actor_create (const std::string& actor_name) {
71
- if (actor_name == "demo") {
72
- return std::make_shared<Demo >();
73
- }
74
- return nullptr;
75
- }
76
-
77
- ```
78
-
79
- ### Hello,World 配置文件
80
- ```json
81
- {
82
- "type":"library",
83
- "lib":"demo",
84
- "actor":{
85
- "demo":[
86
- {
87
- "instance_name":"echo_hello_world",
88
- "instance_params":""
89
- }
90
- ]
91
- }
92
- }
93
- ```
94
- - type: [ library | class ]
95
- - lib: 库名称
96
- - actor: 需要创建的actor列表
97
- - demo: actor名
98
- - instance_name:实例名称
99
- - instance_params:实例参数
43
+ ### Hello,World 组件示例
44
+ - [ 组件代码示例] ( examples/example_actor_helloworld.cpp )
45
+ - [ 组件配置示例] ( examples/example_actor_helloworld.json )
100
46
101
47
## 程序接口
102
- - [ Example] ( https://github.com/lkpworkspace/myframe/tree/master/ examples)
103
- - [ Actor模块] ( https://github.com/lkpworkspace/myframe/blob/master/ myframe/actor.h)
104
- - [ Worker模块] ( https://github.com/lkpworkspace/myframe/blob/master/ myframe/worker.h)
105
- - [ Msg模块] ( https://github.com/lkpworkspace/myframe/blob/master/ myframe/msg.h)
48
+ - [ Example] ( examples )
49
+ - [ Actor模块] ( myframe/actor.h )
50
+ - [ Worker模块] ( myframe/worker.h )
51
+ - [ Msg模块] ( myframe/msg.h )
106
52
107
53
## 文档
108
54
- [ 开发手册] ( doc/development_guide.md )
0 commit comments