Code Monkey home page Code Monkey logo

myframe's Introduction

myframe

myframe

概述

C++实现的组件化的编程框架,程序由actor和worker组成;
actor基于消息驱动,actor之间可以进行消息传递;
worker自驱动,可以通过消息与actor交互;
适用于构建中大型项目.

开发/运行环境

C++ 标准支持
C++17
C++20
操作系统支持
Linux
Windows
macOS

构建

Hello,World 示例

#include <string.h>
#include <iostream>

#include "myframe/msg.h"
#include "myframe/actor.h"

using namespace myframe;
/*
  该actor实现:
    自己给自己发送一条消息
*/
class Demo : public Actor
{
 public:
  /* actor模块加载完毕后调用 */
  int Init(const char* param) override {
    /* 构造 hello,world 消息发送给自己 */
    auto mailbox = GetMailbox();
    mailbox->Send("actor.demo.echo_hello_world", std::make_shared<Msg>("hello,world"));
  }

  void Proc(const std::shared_ptr<const Msg>& msg) override {
    /* 获得文本消息, 打印 源actor地址 目的actor地址 消息内容 */
    std::cout << *msg << ": " << msg->GetData() << std::endl;
  }
};

/* 框架根据描述文件创建actor实例函数 */
extern "C" std::shared_ptr<Actor> actor_create(const std::string& actor_name) {
  if (actor_name == "demo") {
    return std::make_shared<Demo>();
  }
  return nullptr;
}

Hello,World 配置文件

{
  "type":"library",
  "lib":"demo",
  "actor":{
    "demo":[
      {
        "instance_name":"echo_hello_world",
        "instance_params":""
      }
    ]
  }
}
  • type: [ library | class ]
  • lib: 库名称
  • actor: 需要创建的actor列表
    • demo: actor名
      • instance_name:实例名称
      • instance_params:实例参数

程序接口

文档

myframe's People

Contributors

dreamtobedreamer avatar lkpworkspace avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

myframe's Issues

log.cpp 报错

static void signal_handler(const char *data, size_t size) {}
函数前面为int,gcc9.3不能编译通过
改为size_t,编译通过

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.