4 Star 1 Fork 0

Gitee 极速下载 / hereticos-objectsystem

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/yds086/HereticOS-ObjectSystem/
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

HereticOS-ObjectSystem

HereticOS-ObjectSystem是一款C++语言开发的windows平台的轻量级分布式对象系统,使用代码生成器做对象序列化代码生成,对象序列化后可以存储到key value模式的对象服务器中,对象服务器为不同业务程序做对象共享与持久化,支持发布订阅消息推送以及轮询拉取等系统设计模式,是一种敏捷开发利器。技术QQ群(652455784)  

代码目录说明

目录 描述
other\ 序列化库目录
other\ObjectSystem ObjectSystem第一版
other\ObjectSystem2 ObjectSystem第二版
Example\CodeRender 对象序列化代码生成器
Example\ObjectSystemComServer     第一版ObjectSystem的MSSOAP对象服务器
Example\project_WhiteBoxStudio   第一版ObjectSystem框架基础上设计的一款软件,体现敏捷开发的思路。
Example\XMLObjectTest1 c++对象序列化例子
Example\ObjectSystem2Test ObjectSystem第二版测试例子,以及一款击鼓传花的例子。
 
代码需要用VS2017才能编译

ObjectSystem V1介绍  

第一版实做了C++对象序列化,以及对象服务器的基本功能UpdataObject GetObject以及对象锁等,系统在设计时使用KV查询模式,如果需要在不同组件中同步对象,则需要应用自行在KV上设计邮箱,并自行轮询,多组件对相同对象写时需要对对象上锁,以防止对象被不同角色篡改。
第一版传输层使用MSSOAP来实现。

ObjectSystem V2介绍

第二版在第一版基础上使用C++11中的lambda闭包技术实现了异步事件机制,因此增加消息推送能力,从而实现了基于KV对象树模型的发布订阅模式,业务可以注册关注指定对象的UpdataObject NeedObject等事件,由于项目需要第二版ObjectSystem做了不部分重构,暂时去掉了MSSOAP传输层,实做了UDP传输层,未来可能会支持Win10 UWP等。    

第二版目前的问题如下:

1.由于设计之初是为HTTP Soap RPC pull模式设计的,所以底层传输不具备主动推送能力,并且由于主流操作系统的session性能限制,在强行重构到第二版做对象事件发布订阅模式时,底层传输层使用心跳机制来批量拉取事件,因此事件延迟较高,需要大量中间缓存,客户端多了之后心跳压力会非常大,所以在设计系统是应该尽量控制心跳时间,并配合pull模式,不要一味的完全依赖发布订阅模式(20个客户端做击鼓传花测试时,pull轮询推送速度比发布订阅的速度要高)。  

2.由于历史问题,需要xml序列化持久化,由于数据量偏大,所以传输性能并不高,因此性能方面不要强求,但也因此特别适合做敏捷开发,由代码生成器生成xml序列化代码,稍微复杂的业务都可以在短期内实做。
  3.为了支援Win10的异步界面而设计了lambda异步事件推送,但也因此使得一些阻塞的业务流程难以表达,需要增加一些流程控制的辅助代码,比如记录step,击鼓传花例子中大量用step并重入Loop来使的阻塞流程能够正常执行。
  以上问题在异数OS(HereticOS)中得到考虑和解决,异数OS是一种海量阻塞线程模型的操作系统内核,专门为消息推送做了优化,并提供Actor CSP等设计体验,为阻塞业务提供更合理的表达模式

ObjectSystem2Test 击鼓传花例子介绍  

//
//1. 发布订阅消息推送传递模式 适合关注大量对象且需要及时更新业务数据的场合。
//   该模式下所有Client注册关注自己花朵槽Updata事件。
// 管理者放置花朵给一个指定Client的花朵槽时,该Client收到Updata事件,取出花朵等待若干秒后将花朵放入环上下一个用户的花朵槽,下一个用户循环此步骤
//
//2. 轮询拉取传递模式 适合不需要随时跟新业务数据,仅少量对象按需更新业务数据的场合。
// 该模式下所有Client不关注花朵槽事件。
// 所有没有拥有花的Client 定期查询环上上一个用户的花朵槽,如果拥有花朵则取出放入自己的花朵槽。
// Client收到自己花朵槽Updata事件则说明拥有了花朵。
//
//3 管理员公共事件
// 所有Client注册接受管理员邮箱中全局信息对象的Updata事件,管理员Updata设置该对象时广播给所有客户端。
// 比如全局通知,启动关闭暂停,发送广告,重置等。
// 管理员负责初始化用户花朵槽和环,并提供NeedNewSlot服务接口为登陆用户分配一个花朵槽。
//
//4 公告牌广播
// 所有游戏用户关注公告牌,其中用户传递等待时间是管理员动态设置。
//

ObjectSystem V2使用说明

ObjectSystem2Test设计用例:

  1. 设计业务数据对象 RotationalFlowersDataMode.h
  2. 编辑CodeRender\结构体序列化1.1\1.txt脚本,配置好指定代码生成器脚本(MakeTransportProtocol.mk),业务头文件目录(RotationalFlowersDataMode.h),代码输出目录(AppProtocol)等。
  3. 将1.txt拷贝到d:\1.txt
  4. 运行CodeRender,点测试按钮,代码生成好会在AppProtocol目录中
  5. 将AppProtocol目录中所有文件加入到VS项目中。
  6. 编写业务逻辑RotationalFlowers.h

CodeRender 原理以及使用介绍

CodeRender是学生时代的一个玩具,主要做自定义语法文法的模式提取变换,当时网上找到一个C语言编译器的例子用了它的词法分析器然后改了改,上层用借鉴专家系统模式识别的思想做了AST语义树生成,有了AST语义树,同样再用专家系统对AST树做模式识别变换到自己设计的予以模式。 该代码生成器之前做过COM代码HOOK 按照需要做一层Wrap,从而完成一些枯燥的代码编写工作,减少错误。 现在用于对象序列化代码生成。

语义分析语法,实例可以参看CodeRender\结构体序列化1.1\structtree.mk

语言解析表达式规范 + 连接两个规则表达式名称,表示两个规则名指定的表达式按照先后顺序必须都匹配成功(形成多个代码对象)
| 连接两个规则表达式名称,表示两个规则名指定的表达式只要有一个匹配成功则该表达式成功(只针对当前的一个代码对象)
= 包表达式声明定义
N<规则表达式名> 表示指定的规则表达式要做N次匹配,直到当前包结束 无匹配返回状态将结果加入链
包<包起始规则表达式,包终止规则表达式,规则表达式名> 指定一个包的解析匹配规则
xxx<\yyyy> 表示一个语法匹配规则表达式名和表达式类型名 如 函数声明1<函数声明>=返回类型1+调用约定|NULL
NULL<规则表达式名> 表示表达式匹配失败也可返回成功(将填充默认值)
NULL_TRUE 特殊表达式,直接返回表达式匹配成功 用于解析预留接口
NULL_FALSE 特殊表达式,直接返回表达式匹配失败 用于解析预留接口
xxx(yyy) 表示一个词法匹配规则表达式名和表达式类型名 如 句尾1(句尾)=; 词内置类型匹配名有 词型,符号型,整型,浮点型,字符串型,字符型 暂时合并到表达式
ROOT<表达式名> 表示语义解析根入口
G(xxx) 表示一个表达式 G(表达式名1|表达式名2) 暂时不支持
WORD(xxx) 表匹配一个词 比如WORD(;)

代码生成表达式定义,实例可参看 CodeRender\结构体序列化1.1\结构预处理MAKE.mk

表达式为真,则代码返回给上层表达式 MAKE_N<代码节点,第一个代码节点MAKE,中间的过程代码节点MAKE,末尾的代码节点MAKE> 穷举所有符合代码节点表达 式的代码节点,然后交由后面的MAKE表达式处理
MAKE_ONE<代码节点,代码节点MAKE> 只MAKE处理第一个符合代码节点表达式的代码节点
MAKE_ADD<MAKE表达式字符串的表达式名称> 添加或者设置一条表达式
WORD(x) 返回字符串,如果字符串中有"则需要在前面加\
NOT<MAKE表达式> 如果MAKE表达式成功则返回假,用于条件控制执行,并将MAKE表达式的结果抛弃不加入结果链 IF<MAKE表达式> 如果MAKE表达式成功则返回真,用于条件控制执行,并将MAKE表达式的结果抛弃不加入结果链 DEBUGOUT<"字符串"> 打印字符串
DEBUGOUT<MAKE表达式> 打印MAKE表达式生成的结果,并影响参与计算的表达式真假状态
MAKE_TO<MAKE表达式,保存目标对象名> 如果MAKE表达式为真则将其结果保存到目标对象名指定的对象中去
MAKE_MAKECODE<需要解析处理的源对象,处理源对象的脚本对象> 对象可以是一个MAKE表达式返回的字符串,也可以直接是一个对象字符串如文件路径
MAKE_CODE_TO<源对象,处理源对象的MAKE表达式,输出对象> 对象可以是文件路径字符串或者是一个MAKE表达式结果,处理源对象的MAKE表达式 对 源对象分析处理后的结果存入 输出对象
MAKE_BIND_ROUTING<被绑定的虚路径名字符串,需要映射到虚路径的真实路径字符串>
+ 表达式结果连接并流程控制 A+B 如果A为真则执行B,AB都为真则返回真
& 表达式结果连接并流程控制 A&B 不管A执行是否成功,都需执行B, AB只要有一个为真则返回真
# 表达式结果连接并流程控制 A#B 与+意义相同只是返回的结果不是用句连接,而是词的融合
| 表达式结果连接并流程控制 A|B 如果A为真,则不执行B,跳过B执行下一个表达式,如果A为假,则执行B,返回结果为A或B,返回的代码是真值的那个表达式MAKE结果

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright {yyyy} {name of copyright owner} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

HereticOS-ObjectSystem 是一款 C++ 语言开发的 Windows 平台的轻量级分布式对象系统,使用代码生成器做对象序列化代码生成,对象序列化后可以存储到 k 展开 收起
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/mirrors/hereticos-objectsystem.git
git@gitee.com:mirrors/hereticos-objectsystem.git
mirrors
hereticos-objectsystem
hereticos-objectsystem
master

搜索帮助