Operators.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Mon May 10 19:10:37 CEST 2004 Operators.cxx
3 
4  Operators.cxx - description
5  -------------------
6  begin : Mon May 10 2004
7  copyright : (C) 2004 Peter Soetens
8  email : peter.soetens@mech.kuleuven.ac.be
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU General Public *
13  * License as published by the Free Software Foundation; *
14  * version 2 of the License. *
15  * *
16  * As a special exception, you may use this file as part of a free *
17  * software library without restriction. Specifically, if other files *
18  * instantiate templates or use macros or inline functions from this *
19  * file, or you compile this file and link it with other files to *
20  * produce an executable, this file does not by itself cause the *
21  * resulting executable to be covered by the GNU General Public *
22  * License. This exception does not however invalidate any other *
23  * reasons why the executable file might be covered by the GNU General *
24  * Public License. *
25  * *
26  * This library is distributed in the hope that it will be useful, *
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
29  * Lesser General Public License for more details. *
30  * *
31  * You should have received a copy of the GNU General Public *
32  * License along with this library; if not, write to the Free Software *
33  * Foundation, Inc., 59 Temple Place, *
34  * Suite 330, Boston, MA 02111-1307 USA *
35  * *
36  ***************************************************************************/
37 
38 #include "Operators.hpp"
39 #include "OperatorTypes.hpp"
40 #include <functional>
41 
42 // Cappellini Consonni Extension
43 #include "../extras/MultiVector.hpp"
44 
45 #include "../Logger.hpp"
46 #include <boost/type_traits.hpp>
47 #include <boost/shared_ptr.hpp>
48 
49 #include "../internal/mystd.hpp"
50 
51 #include "../rtt-config.h"
52 
53 namespace RTT
54 {
55  using namespace detail;
56 
57  namespace {
58  boost::shared_ptr<OperatorRepository> reg;
59  }
60 
61  boost::shared_ptr<OperatorRepository> OperatorRepository::Instance()
62  {
63  if ( reg )
64  return reg;
65  reg.reset( new OperatorRepository() );
66 
67  return reg;
68  }
69 
70 
71 
73  {
74  }
75 
77  {
78  unaryops.push_back( a );
79  }
80 
82  {
83  binaryops.push_back( b );
84  }
85 
87  {
88  delete_all( unaryops.begin(), unaryops.end() );
89  delete_all( binaryops.begin(), binaryops.end() );
90  }
91 
93  const std::string& op, DataSourceBase* a )
94  {
95  typedef std::vector<UnaryOp*> vec;
96  typedef vec::iterator iter;
97  for ( iter i = unaryops.begin(); i != unaryops.end(); ++i )
98  {
99  DataSourceBase* ret = (*i)->build( op, a );
100  if ( ret ) return ret;
101  }
102  return 0;
103  }
104 
106  const std::string& op, DataSourceBase* a, DataSourceBase* b )
107  {
108  typedef std::vector<BinaryOp*> vec;
109  typedef vec::iterator iter;
110  // First look for an exact match:
111  for ( iter i = binaryops.begin(); i != binaryops.end(); ++i )
112  {
113  if ( (*i)->isExactMatch( op, a, b) )
114  return (*i)->build( op, a, b );
115  }
116  for ( iter i = binaryops.begin(); i != binaryops.end(); ++i )
117  {
118  DataSourceBase* ret = (*i)->build( op, a, b );
119  if ( ret ) return ret;
120  }
121  return 0;
122  }
123 
125  {
126  }
127 
129  {
130  }
131 
134  }
135 }
base::DataSourceBase * applyUnary(const std::string &op, base::DataSourceBase *a)
Definition: Operators.cpp:92
The base class for all internal data representations.
static shared_ptr Instance()
Definition: Operators.cpp:61
RTT_API OperatorRepository::shared_ptr operators()
Definition: Operators.cpp:132
boost::shared_ptr< OperatorRepository > shared_ptr
Definition: Operators.hpp:118
static void delete_all(iter a, iter b)
Definition: mystd.hpp:82
std::vector< BinaryOp * > binaryops
Definition: Operators.hpp:110
std::vector< UnaryOp * > unaryops
Definition: Operators.hpp:109
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53
base::DataSourceBase * applyBinary(const std::string &op, base::DataSourceBase *a, base::DataSourceBase *b)
Definition: Operators.cpp:105


rtt
Author(s): RTT Developers
autogenerated on Tue Jun 25 2019 19:33:26