59 lines
1.6 KiB
C++
59 lines
1.6 KiB
C++
#pragma once
|
|
#include "{{filename name}}.pb.h"
|
|
#include "lib/api/public/ApiServer.h"
|
|
#include "lib/utils/bts_export.h"
|
|
#include <string>
|
|
#include <functional>
|
|
#include <vector>
|
|
#include <set>
|
|
#include <memory>
|
|
|
|
// #include <iostream>
|
|
// #include <atomic>
|
|
namespace bts { namespace api {
|
|
class ServiceContext;
|
|
}}
|
|
|
|
{{ns-open package}}
|
|
|
|
// Forward declaractions
|
|
{{#each message_type}}
|
|
class {{name}};{{/each}}
|
|
|
|
{{#each service}}
|
|
// {{comment}}
|
|
class {{name}}Base : public bts::api::ApiServer {
|
|
protected:
|
|
{{name}}Base(bts::api::ServiceContext& context, const std::string& qualifier="");
|
|
|
|
const char* name() const override;
|
|
|
|
{{#each method}}
|
|
{{#if server_streaming}}
|
|
typedef std::function<void(const std::vector<{{output_type}}>*, const std::vector<{{output_type}}>*, std::set<{{key_type.cpptype}}>*)> {{cap name}}Publisher;
|
|
{{cap name}}Publisher make_{{name}}_publisher() const;
|
|
{{cap name}}Publisher make_{{name}}_publisher(const std::string &) const;
|
|
{{cap name}}Publisher make_{{name}}_publisher(const {{input_type}}& qualifier) const;
|
|
{{else}}
|
|
// {{comment}}
|
|
virtual void {{name}}(const {{input_type}}& request, std::function<void(const {{output_type}}&)> reply) = 0;
|
|
{{/if}}
|
|
{{/each}}
|
|
|
|
enum ServiceMethods {
|
|
SYS_PING = -1,
|
|
{{#each method}}
|
|
{{upper name}} = {{@index}},
|
|
{{/each}}
|
|
};
|
|
|
|
private:
|
|
void dispatch(const bts::api::RequestHeader&, google::protobuf::io::ZeroCopyInputStream&, OnResponse) override;
|
|
{{#each method}}{{#if server_streaming}}
|
|
{{cap name}}Publisher make_{{name}}_publisher(TableHandle) const;
|
|
{{/if}}{{/each}}
|
|
};
|
|
|
|
{{/each}}
|
|
{{ns-close package}}
|