libMesh
parameter_pointer.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_PARAMETER_POINTER_H
21 #define LIBMESH_PARAMETER_POINTER_H
22 
23 
24 // Local Includes
25 #include "libmesh/libmesh_common.h"
26 #include "libmesh/parameter_accessor.h"
27 
28 namespace libMesh
29 {
30 
43 template <typename T=Number>
45 {
46 public:
50  ParameterPointer(T * param_ptr) : _ptr(param_ptr) {}
54  virtual void set (const T & new_value) libmesh_override
55  { libmesh_assert(_ptr); *_ptr = new_value; }
56 
60  virtual const T & get () const libmesh_override
61  { libmesh_assert(_ptr); return *_ptr; }
62 
69 #ifdef LIBMESH_ENABLE_DEPRECATED
70  virtual ParameterAccessor<T> &
71  operator= (T * new_ptr) libmesh_override
72  {
73  libmesh_deprecated();
74  _ptr = new_ptr;
75  return *this;
76  }
77 #endif
78 
82  virtual UniquePtr<ParameterAccessor<T>> clone() const libmesh_override
83  {
85  }
86 
87 private:
88  T * _ptr;
89 };
90 
91 } // namespace libMesh
92 
93 #endif // LIBMESH_PARAMETER_POINTER_H
ParameterPointer(T *param_ptr)
Constructor: take the raw pointer to the parameter.
Accessor object allowing reading and modification of the independent variables in a parameter sensiti...
The libMesh namespace provides an interface to certain functionality in the library.
libmesh_assert(j)
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
virtual UniquePtr< ParameterAccessor< T > > clone() const libmesh_override
virtual ParameterAccessor< T > & operator=(T *new_ptr) libmesh_override
Reseater: change the location of the parameter we access.
Accessor object allowing reading and modification of the independent variables in a parameter sensiti...