NASA Astrobee Robot Software  0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
command.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, United States Government, as represented by the
2  * Administrator of the National Aeronautics and Space Administration.
3  *
4  * All rights reserved.
5  *
6  * The Astrobee platform is licensed under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with the
8  * License. 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, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15  * License for the specific language governing permissions and limitations
16  * under the License.
17  */
18 
19 #ifndef JSONLOADER_COMMAND_H_
20 #define JSONLOADER_COMMAND_H_
21 
22 #include <string>
23 
24 namespace Json {
25 class Value;
26 }
27 
28 namespace jsonloader {
29 
30 class Command {
31  public:
32  virtual ~Command();
33 
34  virtual bool valid() const noexcept;
35  bool blocking() const noexcept;
36  std::string const& type() const noexcept;
37 
38  // Command Factory method to return the correct Command per the JSON object
39  // - returns an empty unique_ptr on failure, which is 'false' in a
40  // boolean context.
41  static Command * Make(Json::Value const& obj);
42 
43  protected:
44  explicit Command(Json::Value const& obj);
45  void set_valid(const bool valid) noexcept;
46 
47  private:
48  bool valid_;
49  bool blocking_;
50  std::string type_;
51 };
52 
53 // Fancy Command constructing function
54 template<typename T>
56  return new T(obj);
57 }
58 
60 
61 } // namespace jsonloader
62 
63 #endif // JSONLOADER_COMMAND_H_
Value
std::pair< std::string, Keywords > Value
Definition: eps_driver_tool.cc:72
jsonloader::Command::Make
static Command * Make(Json::Value const &obj)
Definition: command.cc:49
jsonloader::Command::set_valid
void set_valid(const bool valid) noexcept
Definition: command.cc:107
jsonloader::Command::valid
virtual bool valid() const noexcept
Definition: command.cc:95
jsonloader
Definition: command.h:28
gpio::Value
Value
Definition: GPIO.h:42
Json
Definition: command.h:24
jsonloader::Command::type
std::string const & type() const noexcept
Definition: command.cc:103
jsonloader::Command
Definition: command.h:30
jsonloader::Command::~Command
virtual ~Command()
Definition: command.cc:92
jsonloader::CommandCreateFn
jsonloader::Command *(*)(Json::Value const &obj) CommandCreateFn
Definition: command.h:59
jsonloader::CreateCommand
jsonloader::Command * CreateCommand(Json::Value const &obj)
Definition: command.h:55
jsonloader::Command::blocking
bool blocking() const noexcept
Definition: command.cc:99
jsonloader::Command::Command
Command(Json::Value const &obj)
Definition: command.cc:84