Skip to content

Commit e712282

Browse files
committed
Merge branch 'release/180703'
# Conflicts: # README.md
2 parents 2ad7d6a + 9313ffc commit e712282

31 files changed

+414
-793
lines changed

.gitignore

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,98 @@ lib/
6262
Win32/Debug/ZERO_CHECK/ZERO_CHECK.log
6363
.vscode/settings.json
6464
3rd/
65+
cmake-build-debug/CMakeCache.txt
66+
cmake-build-debug/CMakeFiles/clion-environment.txt
67+
cmake-build-debug/CMakeFiles/clion-log.txt
68+
cmake-build-debug/CMakeFiles/cmake.check_cache
69+
cmake-build-debug/CMakeFiles/CMakeError.log
70+
cmake-build-debug/CMakeFiles/CMakeOutput.log
71+
cmake-build-debug/CMakeFiles/3.10.3/CMakeSystem.cmake
72+
cmake-build-debug/CMakeFiles/3.10.3/CompilerIdC/CMakeCCompilerId.c
73+
cmake-build-debug/CMakeFiles/3.10.3/CompilerIdC/CMakeCCompilerId.o
74+
cmake-build-debug/CMakeFiles/3.10.3/CompilerIdCXX/CMakeCXXCompilerId.cpp
75+
cmake-build-debug/CMakeFiles/3.10.3/CompilerIdCXX/CMakeCXXCompilerId.o
76+
cmake-build-debug/BLOCK.cbp
77+
cmake-build-debug/cmake_install.cmake
78+
cmake-build-debug/Makefile
79+
cmake-build-debug/CMakeFiles/CMakeDirectoryInformation.cmake
80+
cmake-build-debug/CMakeFiles/feature_tests.bin
81+
cmake-build-debug/CMakeFiles/feature_tests.c
82+
cmake-build-debug/CMakeFiles/feature_tests.cxx
83+
cmake-build-debug/CMakeFiles/Makefile.cmake
84+
cmake-build-debug/CMakeFiles/Makefile2
85+
cmake-build-debug/CMakeFiles/progress.marks
86+
cmake-build-debug/CMakeFiles/TargetDirectories.txt
87+
cmake-build-debug/CMakeFiles/3.10.3/CMakeCCompiler.cmake
88+
cmake-build-debug/CMakeFiles/3.10.3/CMakeCXXCompiler.cmake
89+
cmake-build-debug/CMakeFiles/3.10.3/CMakeDetermineCompilerABI_C.bin
90+
cmake-build-debug/CMakeFiles/3.10.3/CMakeDetermineCompilerABI_CXX.bin
91+
cmake-build-debug/core/cmake_install.cmake
92+
cmake-build-debug/core/core.cbp
93+
cmake-build-debug/core/Makefile
94+
cmake-build-debug/core/CMakeFiles/CMakeDirectoryInformation.cmake
95+
cmake-build-debug/core/CMakeFiles/progress.marks
96+
cmake-build-debug/core/CMakeFiles/core.dir/build.make
97+
cmake-build-debug/core/CMakeFiles/core.dir/cmake_clean.cmake
98+
cmake-build-debug/core/CMakeFiles/core.dir/cmake_clean_target.cmake
99+
cmake-build-debug/core/CMakeFiles/core.dir/depend.make
100+
cmake-build-debug/core/CMakeFiles/core.dir/DependInfo.cmake
101+
cmake-build-debug/core/CMakeFiles/core.dir/flags.make
102+
cmake-build-debug/core/CMakeFiles/core.dir/link.txt
103+
cmake-build-debug/core/CMakeFiles/core.dir/progress.make
104+
cmake-build-debug/modules/cmake_install.cmake
105+
cmake-build-debug/modules/Makefile
106+
cmake-build-debug/modules/CMakeFiles/CMakeDirectoryInformation.cmake
107+
cmake-build-debug/modules/CMakeFiles/progress.marks
108+
cmake-build-debug/modules/dbProxy/cmake_install.cmake
109+
cmake-build-debug/modules/dbProxy/dbProxy.cbp
110+
cmake-build-debug/modules/dbProxy/Makefile
111+
cmake-build-debug/modules/dbProxy/CMakeFiles/CMakeDirectoryInformation.cmake
112+
cmake-build-debug/modules/dbProxy/CMakeFiles/progress.marks
113+
cmake-build-debug/modules/dbProxy/CMakeFiles/dbProxy.dir/build.make
114+
cmake-build-debug/modules/dbProxy/CMakeFiles/dbProxy.dir/cmake_clean.cmake
115+
cmake-build-debug/modules/dbProxy/CMakeFiles/dbProxy.dir/cmake_clean_target.cmake
116+
cmake-build-debug/modules/dbProxy/CMakeFiles/dbProxy.dir/depend.make
117+
cmake-build-debug/modules/dbProxy/CMakeFiles/dbProxy.dir/DependInfo.cmake
118+
cmake-build-debug/modules/dbProxy/CMakeFiles/dbProxy.dir/flags.make
119+
cmake-build-debug/modules/dbProxy/CMakeFiles/dbProxy.dir/link.txt
120+
cmake-build-debug/modules/dbProxy/CMakeFiles/dbProxy.dir/progress.make
121+
cmake-build-debug/modules/distributed/cmake_install.cmake
122+
cmake-build-debug/modules/distributed/distributed.cbp
123+
cmake-build-debug/modules/distributed/Makefile
124+
cmake-build-debug/modules/distributed/CMakeFiles/CMakeDirectoryInformation.cmake
125+
cmake-build-debug/modules/distributed/CMakeFiles/progress.marks
126+
cmake-build-debug/modules/distributed/CMakeFiles/distributed.dir/build.make
127+
cmake-build-debug/modules/distributed/CMakeFiles/distributed.dir/cmake_clean.cmake
128+
cmake-build-debug/modules/distributed/CMakeFiles/distributed.dir/cmake_clean_target.cmake
129+
cmake-build-debug/modules/distributed/CMakeFiles/distributed.dir/depend.make
130+
cmake-build-debug/modules/distributed/CMakeFiles/distributed.dir/DependInfo.cmake
131+
cmake-build-debug/modules/distributed/CMakeFiles/distributed.dir/flags.make
132+
cmake-build-debug/modules/distributed/CMakeFiles/distributed.dir/link.txt
133+
cmake-build-debug/modules/distributed/CMakeFiles/distributed.dir/progress.make
134+
cmake-build-debug/modules/luaAdapter/cmake_install.cmake
135+
cmake-build-debug/modules/luaAdapter/luaAdapter.cbp
136+
cmake-build-debug/modules/luaAdapter/Makefile
137+
cmake-build-debug/modules/luaAdapter/CMakeFiles/CMakeDirectoryInformation.cmake
138+
cmake-build-debug/modules/luaAdapter/CMakeFiles/progress.marks
139+
cmake-build-debug/modules/luaAdapter/CMakeFiles/luaAdapter.dir/build.make
140+
cmake-build-debug/modules/luaAdapter/CMakeFiles/luaAdapter.dir/cmake_clean.cmake
141+
cmake-build-debug/modules/luaAdapter/CMakeFiles/luaAdapter.dir/cmake_clean_target.cmake
142+
cmake-build-debug/modules/luaAdapter/CMakeFiles/luaAdapter.dir/depend.make
143+
cmake-build-debug/modules/luaAdapter/CMakeFiles/luaAdapter.dir/DependInfo.cmake
144+
cmake-build-debug/modules/luaAdapter/CMakeFiles/luaAdapter.dir/flags.make
145+
cmake-build-debug/modules/luaAdapter/CMakeFiles/luaAdapter.dir/link.txt
146+
cmake-build-debug/modules/luaAdapter/CMakeFiles/luaAdapter.dir/progress.make
147+
cmake-build-debug/modules/network/cmake_install.cmake
148+
cmake-build-debug/modules/network/Makefile
149+
cmake-build-debug/modules/network/network.cbp
150+
cmake-build-debug/modules/network/CMakeFiles/CMakeDirectoryInformation.cmake
151+
cmake-build-debug/modules/network/CMakeFiles/progress.marks
152+
cmake-build-debug/modules/network/CMakeFiles/network.dir/build.make
153+
cmake-build-debug/modules/network/CMakeFiles/network.dir/cmake_clean.cmake
154+
cmake-build-debug/modules/network/CMakeFiles/network.dir/cmake_clean_target.cmake
155+
cmake-build-debug/modules/network/CMakeFiles/network.dir/depend.make
156+
cmake-build-debug/modules/network/CMakeFiles/network.dir/DependInfo.cmake
157+
cmake-build-debug/modules/network/CMakeFiles/network.dir/flags.make
158+
cmake-build-debug/modules/network/CMakeFiles/network.dir/link.txt
159+
cmake-build-debug/modules/network/CMakeFiles/network.dir/progress.make

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ if(UNIX)
77
set(CMAKE_CXX_FLAGS "-std=c++1y ${CMAKE_CXX_FLAGS}")
88
endif()
99

10+
if (Darwin)
11+
set(CMAKE_CXX_FLAGS "-std=c++1y ${CMAKE_CXX_FLAGS}")
12+
endif()
13+
1014
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
1115
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
1216

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* linux (gcc4.9+
1818
* windows (vs2015+
1919
***
20+
2021
#### 编译&安装
2122
* install.py
2223
***

core/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ if(UNIX)
1717
)
1818
endif()
1919

20+
if (APPLE)
21+
message("APPLE")
22+
INCLUDE_DIRECTORIES(
23+
${BLOCK_SOURCE_DIR}/3rd/fmt
24+
/usr/local/Cellar/gflags/2.2.1/include
25+
/usr/local/Cellar/glog/0.3.5_3/include
26+
)
27+
endif()
28+
2029
Add_Definitions("-DGLOG_NO_ABBREVIATED_SEVERITIES")
2130

2231
#引用库目录

core/appImpl.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,19 @@ block::ModuleID block::AppImpl::getModuleID(const std::string &moduleName) const
9292
}
9393
}
9494

95+
bool block::AppImpl::hasModule(block::ModuleID moduleid)
96+
{
97+
auto _find = std::find_if(module_list_.begin(), module_list_.end(), [&](std::list<Module *>::value_type it) {
98+
return (it->getModuleID() == moduleid);
99+
});
100+
101+
if (_find != module_list_.end()){
102+
return true;
103+
}
104+
105+
return false;
106+
}
107+
95108
const block::AppConfig & block::AppImpl::getAppCfg()
96109
{
97110
return cfg_;
@@ -410,4 +423,4 @@ void block::AppImpl::tick()
410423
last_tick_ = _t;
411424
}
412425
*/
413-
}
426+
}

core/appImpl.hpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include "../depend/event_list.h"
3+
#include "../event_list.h"
44
#include "../utils/single.h"
55
#include "../utils/timer.hpp"
66
#include "../utils/logger.hpp"
@@ -22,18 +22,19 @@ namespace block
2222
class Module;
2323
struct MailBox;
2424
typedef std::shared_ptr<MailBox> MailBoxPtr;
25-
26-
enum AppState
27-
{
28-
BEFORE_INIT = 0,
29-
INIT,
30-
EXECUTE,
31-
SHUT,
32-
AFTER_SHUT,
33-
};
25+
typedef std::function<void(ArgsPtr, int32_t, bool)> RpcCallback;
3426

3527
class AppImpl
3628
{
29+
enum AppState
30+
{
31+
BEFORE_INIT = 0,
32+
INIT,
33+
EXECUTE,
34+
SHUT,
35+
AFTER_SHUT,
36+
};
37+
3738
friend struct MailBox;
3839
public:
3940
AppImpl();
@@ -42,6 +43,8 @@ namespace block
4243

4344
block::ModuleID getModuleID(const std::string &moduleName) const;
4445

46+
bool hasModule(block::ModuleID moduleid);
47+
4548
const block::AppConfig & getAppCfg();
4649

4750
uint64_t getSystemTick();
@@ -131,4 +134,4 @@ namespace block
131134
module_name_map_.insert(std::make_pair(module->getModuleName(), module->getModuleID()));
132135
}
133136
}
134-
}
137+
}

core/application.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ block::ModuleID block::Application::getModuleID(const std::string &moduleName) c
3030
return impl_.getModuleID(moduleName);
3131
}
3232

33+
bool block::Application::hasModule(block::ModuleID moduleid)
34+
{
35+
return impl_.hasModule(moduleid);
36+
}
37+
3338
const block::AppConfig & block::Application::getAppCfg()
3439
{
3540
return impl_.getAppCfg();
@@ -78,4 +83,4 @@ void block::Application::reactorDispatch(block::ModuleID self, block::ModuleID t
7883
void block::Application::reactorBoardcast(block::ModuleID self, block::EventID event, block::ArgsPtr args)
7984
{
8085
impl_.reactorBoardcast(self, event, std::move(args));
81-
}
86+
}

core/application.h

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,58 +11,63 @@ namespace block
1111
Application();
1212

1313
/*!
14-
鑾峰緱杩涚▼鐨勫悕绉?
14+
获取App的名称
1515
**/
1616
std::string getName() const;
1717

1818
/*!
19-
閫氳繃鍚嶅瓧鑾峰彇鏌愪釜Module鐨勫疄渚婭D锛?浠呮敮鎸侀潤鎬佸垱寤虹殑Module銆?
19+
通过名字获取某个Module的实例ID, 仅支持静态创建的Module。
2020
**/
2121
block::ModuleID getModuleID(const std::string &moduleName) const;
2222

2323
/*!
24-
鑾峰彇杩涚▼鐨勬満鍣↖D
24+
* 判断app中是否存在该module
25+
* */
26+
bool hasModule(block::ModuleID moduleid);
27+
28+
/*!
29+
获取App的配置结构
2530
**/
2631
const block::AppConfig & getAppCfg();
2732

2833
/*!
29-
鑾峰緱鍦ㄩ泦缇ゅ唴浜х敓鐨勫敮涓€ID
34+
获取一个uuid
3035
**/
3136
int64_t getUUID();
3237

3338
/*!
34-
鑾峰緱褰撳墠鐨勬绉掓暟
39+
获取app当前的毫秒数
3540
**/
3641
uint64_t getSystemTick();
3742

3843
/*!
39-
鍒濆鍖栬繘绋?
44+
初始化配置文件
4045
**/
4146
void initCfg(const block::AppConfig &cfg);
4247

4348
/*!
44-
鍒涘缓涓€涓狹odule,(杩欎釜鍑芥暟鍙兘浣滅敤浜巃pp.run 涔嬪墠
49+
创建一个静态的Module (只能在App.run之前调用
4550
**/
4651
template <typename T>
4752
void createModule(T *module);
4853

4954
/*!
50-
鍔ㄦ€佸垱寤轰竴涓狹odule
55+
创建一个动态的Module
5156
**/
5257
block::ModuleID createDynamicModule(const std::string &moduleType);
5358

5459
/*!
55-
鍒犻櫎涓€涓狹odule
60+
从App中删除一个Module
5661
**/
5762
void deleteModule(block::ModuleID moduleID);
5863

5964
/*!
60-
杩涚▼鐨勪富寰幆
65+
App的主循环
6166
**/
6267
void run();
6368

6469
/*!
65-
杩涚▼鐨勯€€鍑洪€昏緫
70+
App退出函数
6671
**/
6772
void exit();
6873

@@ -73,7 +78,6 @@ namespace block
7378
void reactorRegist(block::ModuleID moduleID, block::EventID event);
7479
void reactorDispatch(block::ModuleID self, block::ModuleID target, block::EventID event, block::ArgsPtr args);
7580
void reactorBoardcast(block::ModuleID self, block::EventID event, block::ArgsPtr args);
76-
7781
private:
7882
AppImpl impl_;
7983
};

core/args.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef _GSF_ARGS_HEALDER_
2-
#define _GSF_ARGS_HEALDER_
1+
#pragma once
32

43
#include <string>
54
#include <cstring>
@@ -12,7 +11,7 @@
1211
#include <sstream>
1312
#include <functional>
1413

15-
#include "../depend/types.h"
14+
#include "types.h"
1615
#include "../utils/single.h"
1716

1817
namespace block
@@ -361,6 +360,4 @@ namespace block
361360

362361
return args;
363362
}
364-
}
365-
366-
#endif
363+
}

core/module.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ void block::Module::dispatch(block::ModuleID target, block::EventID event, block
3636
mailboxPtr_->dispatch(target, event, std::move(args));
3737
}
3838

39-
void block::Module::rpc(block::EventID event, ArgsPtr args, RpcCallback callback)
40-
{
41-
mailboxPtr_->rpc(event, std::move(args), callback);
42-
}
43-
4439
void block::Module::boardcast(block::EventID event, ArgsPtr args)
4540
{
4641
mailboxPtr_->boardcast(event, std::move(args));
@@ -85,11 +80,6 @@ void block::MailBox::dispatch(block::ModuleID target, block::EventID event, bloc
8580
APP.reactorDispatch(basePtr_->getModuleID(), target, event, std::move(args));
8681
}
8782

88-
void block::MailBox::rpc(block::EventID event, ArgsPtr args, RpcCallback callback /*= nullptr*/)
89-
{
90-
91-
}
92-
9383
void block::MailBox::boardcast(block::EventID event, ArgsPtr args)
9484
{
9585
APP.reactorBoardcast(basePtr_->getModuleID(), event, std::move(args));

0 commit comments

Comments
 (0)