Philote-Cpp
C++ bindings for the Philote MDO standard
Loading...
Searching...
No Matches
discipline_client.h
Go to the documentation of this file.
1/*
2 Philote C++ Bindings
3
4 Copyright 2022-2025 Christopher A. Lupp
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17
18 This work has been cleared for public release, distribution unlimited, case
19 number: AFRL-2023-5716.
20
21 The views expressed are those of the authors and do not reflect the
22 official guidance or position of the United States Government, the
23 Department of Defense or of the United States Air Force.
24
25 Statement from DoD: The Appearance of external hyperlinks does not
26 constitute endorsement by the United States Department of Defense (DoD) of
27 the linked websites, of the information, products, or services contained
28 therein. The DoD does not exercise any editorial, security, or other
29 control over the information you may find at these locations.
30*/
31#pragma once
32
33#include <grpcpp/impl/codegen/status.h>
34#include <grpcpp/impl/codegen/status_code_enum.h>
35#include <grpcpp/support/status.h>
36
37#include <disciplines.grpc.pb.h>
38#include <chrono>
39#include <memory>
40#include <string>
41#include <vector>
42
43namespace philote
44{
55 {
56 public:
62
68 void ConnectChannel(const std::shared_ptr<grpc::ChannelInterface> &channel);
69
74 void GetInfo();
75
81
87 void SendOptions(const philote::DisciplineOptions &options);
88
93 void Setup();
94
100
106
112 std::vector<std::string> GetVariableNames();
113
120 VariableMetaData GetVariableMeta(const std::string &name);
121
127 std::vector<philote::PartialsMetaData> GetPartialsMeta();
128
134 void SetStub(std::unique_ptr<philote::DisciplineService::StubInterface> stub)
135 {
136 stub_ = std::move(stub);
137 }
138
144 const StreamOptions &GetStreamOptions() const noexcept { return stream_options_; }
145
151 void SetStreamOptions(const StreamOptions &options) { stream_options_ = options; }
152
158 const DisciplineProperties &GetProperties() const noexcept { return properties_; }
159
165 void SetProperties(const DisciplineProperties &props) { properties_ = props; }
166
172 const std::vector<VariableMetaData> &GetVariableMetaAll() const noexcept { return var_meta_; }
173
179 void SetVariableMeta(const std::vector<VariableMetaData> &meta) { var_meta_ = meta; }
180
186 const std::vector<PartialsMetaData> &GetPartialsMetaConst() const noexcept { return partials_meta_; }
187
193 void SetPartialsMetaData(const std::vector<PartialsMetaData> &meta) { partials_meta_ = meta; }
194
200 void SetRPCTimeout(std::chrono::milliseconds timeout) { rpc_timeout_ = timeout; }
201
207 std::chrono::milliseconds GetRPCTimeout() const noexcept { return rpc_timeout_; }
208
209 private:
211 std::unique_ptr<philote::DisciplineService::StubInterface> stub_;
212
214 philote::StreamOptions stream_options_;
215
217 philote::DisciplineProperties properties_;
218
220 std::vector<philote::VariableMetaData> var_meta_;
221
223 std::vector<philote::PartialsMetaData> partials_meta_;
224
226 std::chrono::milliseconds rpc_timeout_{60000};
227 };
228} // namespace philote
Client class for interacting with a discipline server.
Definition discipline_client.h:55
void SetProperties(const DisciplineProperties &props)
Set the discipline properties.
Definition discipline_client.h:165
void ConnectChannel(const std::shared_ptr< grpc::ChannelInterface > &channel)
Connect to a gRPC channel.
void SendStreamOptions()
Send the stream options to the server.
const StreamOptions & GetStreamOptions() const noexcept
Get the stream options.
Definition discipline_client.h:144
void SetStreamOptions(const StreamOptions &options)
Set the stream options.
Definition discipline_client.h:151
void SetVariableMeta(const std::vector< VariableMetaData > &meta)
Set the variable metadata.
Definition discipline_client.h:179
const std::vector< VariableMetaData > & GetVariableMetaAll() const noexcept
Get the variable metadata.
Definition discipline_client.h:172
void GetInfo()
Get the discipline info.
void GetPartialDefinitions()
Get the partial definitions from the server.
DisciplineClient()
Construct a new Discipline Client object.
void GetVariableDefinitions()
Get the variable definitions from the server.
void SetStub(std::unique_ptr< philote::DisciplineService::StubInterface > stub)
Set the stub.
Definition discipline_client.h:134
std::chrono::milliseconds GetRPCTimeout() const noexcept
Get the current RPC timeout.
Definition discipline_client.h:207
VariableMetaData GetVariableMeta(const std::string &name)
Get the variable meta data.
void SetRPCTimeout(std::chrono::milliseconds timeout)
Set the RPC timeout for all client operations.
Definition discipline_client.h:200
void SendOptions(const philote::DisciplineOptions &options)
Send the discipline options to the server.
const std::vector< PartialsMetaData > & GetPartialsMetaConst() const noexcept
Get the partials metadata (const version)
Definition discipline_client.h:186
void SetPartialsMetaData(const std::vector< PartialsMetaData > &meta)
Set the partials metadata.
Definition discipline_client.h:193
void Setup()
Setup the discipline.
const DisciplineProperties & GetProperties() const noexcept
Get the discipline properties.
Definition discipline_client.h:158
std::vector< philote::PartialsMetaData > GetPartialsMeta()
Get the partials meta data.
std::vector< std::string > GetVariableNames()
Get the variable names.
Definition discipline.h:43