cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mtsFunctionQualifiedRead.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): Peter Kazanzides, Anton Deguet
7 
8  (C) Copyright 2007-2014 Johns Hopkins University (JHU), All Rights Reserved.
9 
10 --- begin cisst license - do not edit ---
11 
12 This software is provided "as is" under an open source license, with
13 no warranty. The complete license can be found in license.txt and
14 http://www.cisst.org/cisst/license.txt.
15 
16 --- end cisst license ---
17 */
18 
19 
25 #ifndef _mtsFunctionQualifiedRead_h
26 #define _mtsFunctionQualifiedRead_h
27 
28 
33 
34 // Always include last
36 
38 public:
40 protected:
42 
43 #ifndef SWIG
44  // Portability note: Visual Studio.NET 2003 did not compile with following (Error C2365), needed to add "a" and "b".
45  // template<typename _userType1, typename _userType2, bool, bool>
46  template <typename _userType1, typename _userType2, bool a, bool b>
48  // default case: both parameters need to be wrapped
49  public:
51  const _userType1 & argument1, _userType2 & argument2) {
52  const mtsGenericObjectProxyRef<_userType1> argument1Wrapped(argument1);
53  mtsGenericObjectProxyRef<_userType2> argument2Wrapped(argument2);
54  return function->ExecuteGeneric(argument1Wrapped, argument2Wrapped);
55  }
56  };
57  template <typename _userType1, typename _userType2>
58  class ConditionalWrap<_userType1, _userType2, false, true> {
59  // specialization: only first parameter needs to be wrapped
60  public:
62  const _userType1 & argument1, _userType2 & argument2) {
63  const mtsGenericObjectProxyRef<_userType1> argument1Wrapped(argument1);
64  return function->ExecuteGeneric(argument1Wrapped, argument2);
65  }
66  };
67  template <typename _userType1, typename _userType2>
68  class ConditionalWrap<_userType1, _userType2, true, false> {
69  // specialization: only second parameter needs to be wrapped
70  public:
72  const _userType1 & argument1, _userType2 & argument2) {
73  mtsGenericObjectProxyRef<_userType2> argument2Wrapped(argument2);
74  return function->ExecuteGeneric(argument1, argument2Wrapped);
75  }
76  };
77  template <typename _userType1, typename _userType2>
78  class ConditionalWrap<_userType1, _userType2, true, true> {
79  // specialization: neither parameter needs to be wrapped
80  public:
82  const _userType1 & argument1, _userType2 & argument2) {
83  return function->ExecuteGeneric(argument1, argument2);
84  }
85  };
86 #endif
87 
88  public:
92 
95 
96  // documented in base class
97  bool Detach(void);
98 
99  // documented in base class
100  bool IsValid(void) const;
101 
107  bool Bind(CommandType * command);
108 
112  mtsGenericObject & argument) const
113  { return ExecuteGeneric(qualifier, argument); }
114 
115  mtsExecutionResult ExecuteGeneric(const mtsGenericObject & qualifier,
116  mtsGenericObject & argument) const;
117 
118 #ifndef SWIG
119 
120  template <class _userType1, class _userType2>
121  mtsExecutionResult operator()(const _userType1 & argument1, _userType2 & argument2) const
122  { return Execute(argument1, argument2); }
123 
124  template <class _userType1, class _userType2>
125  mtsExecutionResult Execute(const _userType1 & argument1, _userType2 & argument2) const {
126  mtsExecutionResult result = Command ?
127  ConditionalWrap<_userType1, _userType2,
129  cmnIsDerivedFrom<_userType2, mtsGenericObject>::IS_DERIVED>::Call(this, argument1, argument2)
131  return result;
132  }
133 #endif
134 
136  CommandType * GetCommand(void) const;
137 
139  const mtsGenericObject * GetArgument1Prototype(void) const;
140 
142  const mtsGenericObject * GetArgument2Prototype(void) const;
143 
145  void ToStream(std::ostream & outputStream) const;
146 };
147 
148 #endif // _mtsFunctionQualifiedRead_h
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
Definition: cmnTypeTraits.h:564
Definition: mtsFunctionQualifiedRead.h:37
Definition: mtsFunctionQualifiedRead.h:47
virtual void ToStream(std::ostream &outputStream) const =0
Base class for data object in cisstMultiTask.
Definition: mtsGenericObject.h:56
Definition: mtsFunctionBase.h:38
Defines a base function object to allow heterogeneous containers of functions.
mtsExecutionResult Execute(const _userType1 &argument1, _userType2 &argument2) const
Definition: mtsFunctionQualifiedRead.h:125
static mtsExecutionResult Call(const mtsFunctionQualifiedRead *function, const _userType1 &argument1, _userType2 &argument2)
Definition: mtsFunctionQualifiedRead.h:81
virtual bool Detach(void)=0
Definition: mtsExecutionResult.h:44
Forward declarations and #define for cisstMultiTask.
mtsExecutionResult operator()(const mtsGenericObject &qualifier, mtsGenericObject &argument) const
Definition: mtsFunctionQualifiedRead.h:111
Definition: mtsGenericObjectProxy.h:46
Definition: mtsCommandQualifiedRead.h:39
CommandType * Command
Definition: mtsFunctionQualifiedRead.h:41
Definition: mtsExecutionResult.h:34
Defines a command with one argument.
mtsCommandQualifiedRead CommandType
Definition: mtsFunctionQualifiedRead.h:39
static mtsExecutionResult Call(const mtsFunctionQualifiedRead *function, const _userType1 &argument1, _userType2 &argument2)
Definition: mtsFunctionQualifiedRead.h:71
Rules of exporting.
mtsExecutionResult operator()(const _userType1 &argument1, _userType2 &argument2) const
Definition: mtsFunctionQualifiedRead.h:121
static mtsExecutionResult Call(const mtsFunctionQualifiedRead *function, const _userType1 &argument1, _userType2 &argument2)
Definition: mtsFunctionQualifiedRead.h:50
static mtsExecutionResult Call(const mtsFunctionQualifiedRead *function, const _userType1 &argument1, _userType2 &argument2)
Definition: mtsFunctionQualifiedRead.h:61
virtual bool IsValid(void) const =0