cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mtsCommandBase.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3 
4 /*
5 
6  Author(s): Ankur Kapoor, Anton Deguet
7  Created on: 2006-05-02
8 
9  (C) Copyright 2006-2009 Johns Hopkins University (JHU), All Rights
10  Reserved.
11 
12 --- begin cisst license - do not edit ---
13 
14 This software is provided "as is" under an open source license, with
15 no warranty. The complete license can be found in license.txt and
16 http://www.cisst.org/cisst/license.txt.
17 
18 --- end cisst license ---
19 */
20 
21 
27 #ifndef _mtsCommandBase_h
28 #define _mtsCommandBase_h
29 
30 // These two includes are not required to compile this class but are
31 // pretty much always needed in conjunction with commands. To ease
32 // the user's life, we include them now.
33 //include <cisstMultiTask/mtsGenericObjectProxy.h>
36 
37 #include <iostream>
38 #include <sstream>
39 
44 
45 private:
47  inline mtsCommandBase(const mtsCommandBase & CMN_UNUSED(other));
48 
49 protected:
52  std::string Name;
53 
58  bool EnableFlag;
59 
60 public:
62  inline mtsCommandBase(void):
63  Name("??"),
64  EnableFlag(true)
65  {}
66 
68  inline mtsCommandBase(const std::string & name):
69  Name(name),
70  EnableFlag(true)
71  {}
72 
74  virtual ~mtsCommandBase() {}
75 
79  virtual std::string ToString(void) const {
80  std::stringstream outputStream;
81  ToStream(outputStream);
82  return outputStream.str();
83  };
84  virtual void ToStream(std::ostream & outputStream) const = 0;
86 
89  virtual size_t NumberOfArguments(void) const = 0;
90 
91  virtual bool Returns(void) const = 0;
92 
97  inline void Enable(void) {
98  this->EnableFlag = true;
99  }
100 
101  inline void Disable(void) {
102  this->EnableFlag = false;
103  }
104 
105  inline bool IsEnabled(void) const {
106  return this->EnableFlag;
107  }
108 
109  inline bool IsDisabled(void) const {
110  return !(this->EnableFlag);
111  }
113 
116  inline const std::string & GetName(void) const {
117  return this->Name;
118  }
119 };
120 
121 
125 inline std::ostream & operator << (std::ostream & outputStream,
126  const mtsCommandBase & command) {
127  command.ToStream(outputStream);
128  return outputStream;
129 }
130 
131 
132 #endif // _mtsCommandBase_h
133 
virtual size_t NumberOfArguments(void) const =0
bool IsEnabled(void) const
Definition: mtsCommandBase.h:105
#define CMN_UNUSED(argument)
Definition: cmnPortability.h:479
virtual void ToStream(std::ostream &outputStream) const =0
bool IsDisabled(void) const
Definition: mtsCommandBase.h:109
mtsCommandBase(void)
Definition: mtsCommandBase.h:62
std::string Name
Definition: mtsCommandBase.h:52
bool EnableFlag
Definition: mtsCommandBase.h:58
Forward declarations and #define for cisstMultiTask.
virtual ~mtsCommandBase()
Definition: mtsCommandBase.h:74
virtual bool Returns(void) const =0
mtsCommandBase(const std::string &name)
Definition: mtsCommandBase.h:68
void Enable(void)
Definition: mtsCommandBase.h:97
virtual std::string ToString(void) const
Definition: mtsCommandBase.h:79
const std::string & GetName(void) const
Definition: mtsCommandBase.h:116
void Disable(void)
Definition: mtsCommandBase.h:101
Definition: mtsCommandBase.h:43
std::ostream & operator<<(std::ostream &outputStream, const mtsCommandBase &command)
Definition: mtsCommandBase.h:125