cisst-saw
Loading...
Searching...
No Matches
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
12This software is provided "as is" under an open source license, with
13no warranty. The complete license can be found in license.txt and
14http://www.cisst.org/cisst/license.txt.
15
16--- end cisst license ---
17*/
18
19
24
25#ifndef _mtsFunctionQualifiedRead_h
26#define _mtsFunctionQualifiedRead_h
27
28
33
34// Always include last
36
38public:
40protected:
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
116 mtsGenericObject & argument) const;
117
118#ifndef SWIG
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
140
143
145 void ToStream(std::ostream & outputStream) const;
146};
147
148#endif // _mtsFunctionQualifiedRead_h
@ IS_DERIVED
Definition cmnTypeTraits.h:622
Definition mtsCommandQualifiedRead.h:40
Definition mtsExecutionResult.h:34
@ FUNCTION_NOT_BOUND
Definition mtsExecutionResult.h:44
static mtsExecutionResult Call(const mtsFunctionQualifiedRead *function, const _userType1 &argument1, _userType2 &argument2)
Definition mtsFunctionQualifiedRead.h:61
static mtsExecutionResult Call(const mtsFunctionQualifiedRead *function, const _userType1 &argument1, _userType2 &argument2)
Definition mtsFunctionQualifiedRead.h:71
static mtsExecutionResult Call(const mtsFunctionQualifiedRead *function, const _userType1 &argument1, _userType2 &argument2)
Definition mtsFunctionQualifiedRead.h:81
Definition mtsFunctionQualifiedRead.h:47
static mtsExecutionResult Call(const mtsFunctionQualifiedRead *function, const _userType1 &argument1, _userType2 &argument2)
Definition mtsFunctionQualifiedRead.h:50
bool Bind(CommandType *command)
const mtsGenericObject * GetArgument1Prototype(void) const
mtsExecutionResult operator()(const _userType1 &argument1, _userType2 &argument2) const
Definition mtsFunctionQualifiedRead.h:121
bool IsValid(void) const
const mtsGenericObject * GetArgument2Prototype(void) const
CommandType * Command
Definition mtsFunctionQualifiedRead.h:41
CommandType * GetCommand(void) const
mtsExecutionResult ExecuteGeneric(const mtsGenericObject &qualifier, mtsGenericObject &argument) const
mtsExecutionResult Execute(const _userType1 &argument1, _userType2 &argument2) const
Definition mtsFunctionQualifiedRead.h:125
void ToStream(std::ostream &outputStream) const
mtsExecutionResult operator()(const mtsGenericObject &qualifier, mtsGenericObject &argument) const
Definition mtsFunctionQualifiedRead.h:111
mtsCommandQualifiedRead CommandType
Definition mtsFunctionQualifiedRead.h:39
Base class for data object in cisstMultiTask.
Definition mtsGenericObject.h:52
Definition mtsGenericObjectProxy.h:491
#define CISST_EXPORT
Definition cmnExportMacros.h:50
Defines a command with one argument.
Rules of exporting.
Forward declarations and #define for cisstMultiTask.
Defines a base function object to allow heterogeneous containers of functions.