Logo  0.95.0-final
Finite Element Embedded Library and Language in C++
Feel++ Feel++ on Github Feel++ community
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
feelcore/context.hpp
1 /* -*- mode: c++; coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; show-trailing-whitespace: t -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2 
3  This file is part of the Feel library
4 
5  Author(s): Christophe Prud'homme <christophe.prudhomme@feelpp.org>
6  Date: 2005-03-08
7 
8  Copyright (C) 2009 Université de Grenoble 1
9  Copyright (C) 2005,2006 EPFL
10 
11  This library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU Lesser General Public
13  License as published by the Free Software Foundation; either
14  version 3.0 of the License, or (at your option) any later version.
15 
16  This library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  Lesser General Public License for more details.
20 
21  You should have received a copy of the GNU Lesser General Public
22  License along with this library; if not, write to the Free Software
23  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 */
30 #ifndef __Context_H
31 #define __Context_H 1
32 
33 #include <feel/feelcore/feel.hpp>
34 
35 namespace Feel
36 {
37 
38 template<size_type Contextv, size_type Value>
39 struct has_value
40 {
41  static const bool value = ( Contextv & Value ) != 0;
42 };
43 
44 template<size_type Contextv, size_type Value>
45 struct set_value
46 {
47  static const bool value = ( Contextv | Value );
48 };
49 
50 template<size_type Contextv, size_type Value>
51 struct clear_value
52 {
53  static const bool value = Contextv & ( ~Value );
54 };
55 
63 class Context
64 {
65 public:
66 
70 
76  explicit Context( size_type c )
77  :
78  M_context( c )
79  {}
80 
85  Context( Context const & c )
86  :
87  M_context( c.M_context )
88  {}
89 
95  {}
96 
98 
102 
108  Context& operator=( Context const& __c )
109  {
110  if ( this != &__c )
111  {
112  M_context = __c.M_context;
113  }
114 
115  return *this;
116  }
117 
124  {
125  M_context = __c;
126  return *this;
127  }
128 
135  {
136  return M_context;
137  }
138 
140 
144 
151  {
152  return M_context;
153  }
154 
155 
157 
161 
167  void setContext( size_type __v )
168  {
169  M_context = __v ;
170  }
171 
172 
174 
178 
179 
180  bool test( size_type b ) const
181  {
182  return ( M_context&b )!=0;
183  }
184  template<typename T> bool test( T b ) const
185  {
186  return ( M_context&size_type( b ) )!=0;
187  }
188  void set( size_type b )
189  {
190  M_context |= b;
191  }
192  void set( size_type b, bool v );
193  void clear( size_type b )
194  {
195  M_context &= ( uint )( ~b );
196  }
197  void reset()
198  {
199  M_context = 0;
200  }
201 
203 
204 private:
205 
206  friend class boost::serialization::access;
207  template<class Archive>
208  void serialize( Archive & ar, const unsigned int version )
209  {
210  ar & M_context;
211  }
212 
213 private:
214 
215  size_type M_context;
216 
217 };
218 }
219 #endif /* __Context_H */
size_type operator()() const
Definition: feelcore/context.hpp:134
void setContext(size_type __v)
Definition: feelcore/context.hpp:167
Context & operator=(Context const &__c)
Definition: feelcore/context.hpp:108
Context(Context const &c)
Definition: feelcore/context.hpp:85
~Context()
Definition: feelcore/context.hpp:94
Context & operator=(size_type __c)
Definition: feelcore/context.hpp:123
size_type context() const
Definition: feelcore/context.hpp:150
size_t size_type
Indices (starting from 0)
Definition: feelcore/feel.hpp:319
Context class.
Definition: feelcore/context.hpp:63
Context(size_type c)
Definition: feelcore/context.hpp:76

Generated on Sun Dec 22 2013 13:10:55 for Feel++ by doxygen 1.8.5