reset.h
Go to the documentation of this file.
1 /*
2  * Copyright 2020-2021 The urg_stamped Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef SCIP2_RESPONSE_RESET_H
18 #define SCIP2_RESPONSE_RESET_H
19 
20 #include <boost/asio.hpp>
21 
22 #include <string>
23 
25 
26 namespace scip2
27 {
28 class ResponseRS : public Response
29 {
30 public:
31  using Callback = boost::function<void(
32  const boost::posix_time::ptime&,
33  const std::string&,
34  const std::string&)>;
35 
36 protected:
38 
39 public:
40  std::string getCommandCode() const
41  {
42  return std::string("RS");
43  }
44  void operator()(
45  const boost::posix_time::ptime& time_read,
46  const std::string& echo_back,
47  const std::string& status,
48  std::istream& stream)
49  {
50  if (cb_)
51  {
52  cb_(time_read, echo_back, status);
53  }
54  readUntilEnd(stream);
55  }
57  {
58  cb_ = cb;
59  }
60 };
61 
62 class ResponseRT : public Response
63 {
64 public:
65  using Callback = boost::function<void(
66  const boost::posix_time::ptime&,
67  const std::string&,
68  const std::string&)>;
69 
70 protected:
72 
73 public:
74  std::string getCommandCode() const
75  {
76  return std::string("RT");
77  }
78  void operator()(
79  const boost::posix_time::ptime& time_read,
80  const std::string& echo_back,
81  const std::string& status,
82  std::istream& stream)
83  {
84  if (cb_)
85  {
86  cb_(time_read, echo_back, status);
87  }
88  readUntilEnd(stream);
89  }
91  {
92  cb_ = cb;
93  }
94 };
95 } // namespace scip2
96 
97 #endif // SCIP2_RESPONSE_RESET_H
scip2::Response
Definition: abstract.h:27
scip2::ResponseRT::registerCallback
void registerCallback(Callback cb)
Definition: reset.h:90
scip2::ResponseRT
Definition: reset.h:62
scip2::readUntilEnd
void readUntilEnd(std::istream &stream)
Definition: abstract.h:39
scip2::ResponseRS::registerCallback
void registerCallback(Callback cb)
Definition: reset.h:56
scip2::ResponseRT::operator()
void operator()(const boost::posix_time::ptime &time_read, const std::string &echo_back, const std::string &status, std::istream &stream)
Definition: reset.h:78
scip2::ResponseRT::cb_
Callback cb_
Definition: reset.h:71
scip2
Definition: connection.h:30
scip2::ResponseRT::Callback
boost::function< void(const boost::posix_time::ptime &, const std::string &, const std::string &)> Callback
Definition: reset.h:68
scip2::ResponseRS::getCommandCode
std::string getCommandCode() const
Definition: reset.h:40
scip2::ResponseRS
Definition: reset.h:28
scip2::ResponseRS::cb_
Callback cb_
Definition: reset.h:37
scip2::ResponseRS::Callback
boost::function< void(const boost::posix_time::ptime &, const std::string &, const std::string &)> Callback
Definition: reset.h:34
scip2::ResponseRS::operator()
void operator()(const boost::posix_time::ptime &time_read, const std::string &echo_back, const std::string &status, std::istream &stream)
Definition: reset.h:44
scip2::ResponseRT::getCommandCode
std::string getCommandCode() const
Definition: reset.h:74
abstract.h


urg_stamped
Author(s): Atsushi Watanabe
autogenerated on Wed Dec 18 2024 03:10:57