Wolframe, 0.0.3

filter.hpp
Go to the documentation of this file.
1 /************************************************************************
2 Copyright (C) 2011 - 2014 Project Wolframe.
3 All rights reserved.
4 
5 This file is part of Project Wolframe.
6 
7 Commercial Usage
8 Licensees holding valid Project Wolframe Commercial licenses may
9 use this file in accordance with the Project Wolframe
10 Commercial License Agreement provided with the Software or,
11 alternatively, in accordance with the terms contained
12 in a written agreement between the licensee and Project Wolframe.
13 
14 GNU General Public License Usage
15 Alternatively, you can redistribute this file and/or modify it
16 under the terms of the GNU General Public License as published by
17 the Free Software Foundation, either version 3 of the License, or
18 (at your option) any later version.
19 
20 Wolframe is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24 
25 You should have received a copy of the GNU General Public License
26 along with Wolframe. If not, see <http://www.gnu.org/licenses/>.
27 
28 If you have questions regarding the use of this file, please contact
29 Project Wolframe.
30 
31 ************************************************************************/
34 
35 #ifndef _Wolframe_FILTER_FILTER_INTERFACE_HPP_INCLUDED
36 #define _Wolframe_FILTER_FILTER_INTERFACE_HPP_INCLUDED
37 #include "filter/inputfilter.hpp"
38 #include "filter/outputfilter.hpp"
39 #include <string>
40 #include <vector>
41 #include <utility>
42 #include <boost/shared_ptr.hpp>
43 
44 namespace _Wolframe {
45 namespace langbind {
46 
49 class Filter
50 {
51 public:
53  Filter( const InputFilterR& i_, const OutputFilterR& o_)
55  {
56  if (i_.get())
57  {
58  m_outputfilter->inheritMetaData( m_inputfilter->getMetaDataRef());
59  }
60  }
62  Filter( const Filter& o)
65  Filter(){}
66 
68  const InputFilterR& inputfilter() const {return m_inputfilter;}
70  const OutputFilterR& outputfilter() const {return m_outputfilter;}
75 
80  bool getValue( const char* name, std::string& val) const
81  {
82  if (m_inputfilter.get() && m_inputfilter->getValue( name, val)) return true;
83  if (m_outputfilter.get() && m_outputfilter->getValue( name, val)) return true;
84  return false;
85  }
86 
91  bool setValue( const char* name, const std::string& value)
92  {
93  bool rt = false;
94  if (m_inputfilter.get() && m_inputfilter->setValue( name, value)) rt = true;
95  if (m_outputfilter.get() && m_outputfilter->setValue( name, value)) rt = true;
96  return rt;
97  }
98 
99 protected:
102 };
103 
104 typedef boost::shared_ptr<Filter> FilterR;
105 
106 
107 typedef std::pair<std::string,std::string> FilterArgument;
108 
112 {
113 public:
115  explicit FilterType( const char* name_)
116  :m_name(name_){}
119  :m_name(o.m_name){}
120 
122  virtual ~FilterType(){}
124  virtual Filter* create( const std::vector<FilterArgument>& arg = std::vector<FilterArgument>()) const=0;
125 
127  const char* name() const
128  {return m_name;}
129 private:
130  const char* m_name;
131 };
132 
133 typedef boost::shared_ptr<FilterType> FilterTypeR;
134 
136 typedef FilterType* (*CreateFilterType)();
137 
138 }}//namespace
139 #endif
140 
141 
virtual ~FilterType()
Destructor.
Definition: filter.hpp:122
const char * m_name
Definition: filter.hpp:130
Filter(const InputFilterR &i_, const OutputFilterR &o_)
Constructor.
Definition: filter.hpp:53
std::pair< std::string, std::string > FilterArgument
Definition: filter.hpp:107
Filter()
Default constructor.
Definition: filter.hpp:65
Structure defining a filter for input and output as unit.
Definition: filter.hpp:49
boost::shared_ptr< Filter > FilterR
Definition: filter.hpp:104
FilterType(const char *name_)
Constructor.
Definition: filter.hpp:115
virtual Filter * create(const std::vector< FilterArgument > &arg=std::vector< FilterArgument >()) const =0
Get a new filter instance.
OutputFilterR m_outputfilter
Definition: filter.hpp:101
const InputFilterR & inputfilter() const
Get the associated input filter reference.
Definition: filter.hpp:68
Structure defining a type of a filter (used as virtual constructor to create filter instances) ...
Definition: filter.hpp:111
boost::shared_ptr< FilterType > FilterTypeR
Definition: filter.hpp:133
bool setValue(const char *name, const std::string &value)
Set a member value of the filter.
Definition: filter.hpp:91
bool getValue(const char *name, std::string &val) const
Get a member value of the filter.
Definition: filter.hpp:80
OutputFilterR & outputfilter()
Get the associated output filter reference.
Definition: filter.hpp:74
OBJ * get() const
Get the pointer to the object.
Definition: sharedReference.hpp:88
InputFilterR & inputfilter()
Get the associated input filter reference.
Definition: filter.hpp:72
const OutputFilterR & outputfilter() const
Get the associated output filter reference.
Definition: filter.hpp:70
Interface for output filter.
Interface for input filter.
FilterType(const FilterType &o)
Copy constructor.
Definition: filter.hpp:118
InputFilterR m_inputfilter
Definition: filter.hpp:100
const char * name() const
Get the name of the filter.
Definition: filter.hpp:127
Filter(const Filter &o)
Copy constructor.
Definition: filter.hpp:62