Wolframe, 0.0.3

envelopefilter.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 ************************************************************************/
35 
36 #ifndef _Wolframe_FILTER_ENVELOPE_FILTER_INTERFACE_HPP_INCLUDED
37 #define _Wolframe_FILTER_ENVELOPE_FILTER_INTERFACE_HPP_INCLUDED
38 #include "filter/typedfilter.hpp"
39 #include <boost/shared_ptr.hpp>
40 
41 namespace _Wolframe {
42 namespace langbind {
43 
46 template <class Context>
48  :public TypedInputFilter
49 {
50 public:
51  typedef boost::shared_ptr<Context> ContextR;
52 
55  :TypedInputFilter(i->name())
56  ,m_context(c)
57  ,m_input(i){}
58 
64  ,m_input(o.m_input){}
65 
68  {
69  m_input.reset();
70  }
71 
74  virtual TypedInputFilter* copy() const
75  {
76  return new EnvelopeInputFilter(*this);
77  }
78 
85  virtual bool getNext( ElementType& type, types::VariantConst& element)
86  {
87  return m_input->getNext( type, element);
88  }
89 
91  virtual void resetIterator()
92  {
93  m_input->resetIterator();
94  }
95 
97  virtual bool setFlags( Flags f)
98  {
99  if (m_input->setFlags(f))
100  {
101  return TypedInputFilter::setFlags(f);
102  }
103  return false;
104  }
105 
107  virtual bool checkSetFlags( Flags f) const
108  {
109  return m_input->checkSetFlags(f);
110  }
111 
113  virtual const char* getError() const
114  {
115  return m_input->getError();
116  }
117 
118 private:
119  boost::shared_ptr<Context> m_context;
121 };
122 
123 }}//namespace
124 #endif
TypedInputFilterR m_input
Definition: envelopefilter.hpp:120
Envelope for a input filter and its context.
Definition: envelopefilter.hpp:47
EnvelopeInputFilter(const TypedInputFilterR &i, const ContextR &c)
Constructor.
Definition: envelopefilter.hpp:54
virtual TypedInputFilter * copy() const
Get a self copy.
Definition: envelopefilter.hpp:74
virtual bool checkSetFlags(Flags f) const
Test if a flag can be set (allowed)
Definition: envelopefilter.hpp:107
EnvelopeInputFilter(const EnvelopeInputFilter &o)
Copy constructor.
Definition: envelopefilter.hpp:61
Flags
Definition: filterbase.hpp:106
virtual ~EnvelopeInputFilter()
Destructor.
Definition: envelopefilter.hpp:67
const char * name() const
Get the name of the filter.
Definition: filterbase.hpp:129
Variant value type that represents a variant copy without content ownership.
Definition: variant.hpp:286
boost::shared_ptr< TypedInputFilter > TypedInputFilterR
Shared input filter (langbind::TypedInputFilter) reference.
Definition: typedfilter.hpp:98
virtual bool setFlags(Flags f)
Set a flag (or a set of flags)
Definition: filterbase.hpp:124
ElementType
Content element type that describes the role of the element in the structured input.
Definition: filterbase.hpp:66
boost::shared_ptr< Context > m_context
Definition: envelopefilter.hpp:119
virtual bool setFlags(Flags f)
Set a flag (or a set of flags)
Definition: envelopefilter.hpp:97
virtual const char * getError() const
Get the last error.
Definition: envelopefilter.hpp:113
virtual bool getNext(ElementType &type, types::VariantConst &element)
Get next element.
Definition: envelopefilter.hpp:85
boost::shared_ptr< Context > ContextR
Definition: envelopefilter.hpp:51
virtual void resetIterator()
Set the iterator to the start (if implemented)
Definition: envelopefilter.hpp:91
Typed interface for input/output filter.
Input filter with atomic values having a type.
Definition: typedfilter.hpp:48