GemaCoreLib
The GeMA Core library
gmAccessorProxy.h
Go to the documentation of this file.
1 /************************************************************************
2 **
3 ** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4 ** All rights reserved.
5 **
6 ** This file is part of the "GeMA" software. It's use should respect
7 ** the terms in the license agreement that can be found together
8 ** with this source code.
9 ** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10 ** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11 ** A PARTICULAR PURPOSE.
12 **
13 ************************************************************************/
14 
25 #ifndef _GEMA_ACCESSOR_PROXY_H_
26 #define _GEMA_ACCESSOR_PROXY_H_
27 
28 #include "gmValueAccessor.h"
29 
30 #include <assert.h>
31 
32 
39 {
40 public:
42  GmAccessorProxy(GmValueAccessor* ac) { assert(ac); _ac = ac; }
43 
45  virtual ~GmAccessorProxy() { delete _ac; }
46 
47  int size() const { return _ac->size(); }
48  GmValueInfo* info() const { return _ac->info(); }
49  bool isScalar() const { return _ac->isScalar(); }
50  Unit unit() const { return _ac->unit(); }
51  int valueSize() const { return _ac->valueSize(); }
52  const double* defValue() const { return _ac->defValue(); }
53 
54 protected:
58  double convertToAccessorUnit(double val) const { return _ac->convertToAccessorUnit(val); }
59 
64  const double* convertToAccessorUnit(const double* p) const { return _ac->convertToAccessorUnit(p); }
65 
67  void convertFromAccessorUnit(double val, double* dst) const { return _ac->convertFromAccessorUnit(val, dst); }
68 
70  void convertFromAccessorUnit(const double* val, double* dst) const { return _ac->convertFromAccessorUnit(val, dst); }
71 
72  // State dump interface needs to get the base value accessor used by Cell, Gauss and BC acessors
73  // The same feature is used by GmHdf5 to improve performance
74  friend class GmStateDump;
75  friend class GmHdf5;
76 
77  GmValueAccessor* _ac;
78 };
79 
80 
81 #endif
82 
Auxiliar class used to store the definition of a value. It can be used to store informations about st...
Definition: gmValueInfo.h:126
const double * convertToAccessorUnit(const double *p) const
An utility function that given a pointer to the stored data, converts the value to the accessor unit ...
Definition: gmAccessorProxy.h:64
The GmStateDump class presents a higher level of abstraction over GmMemoryDump, storing accessor data...
Definition: gmStateDump.h:52
A support class for saving data to a HDF5 file. Hdf5 files are self-describing but do not have a fixe...
Definition: gmHdf5.h:65
void convertFromAccessorUnit(double val, double *dst) const
Copies the value given by val into the area pointed to by dst, converting units if needed.
Definition: gmAccessorProxy.h:67
Interface class for accessing and setting values from an "indexable" collection of values.
Definition: gmValueAccessor.h:59
virtual ~GmAccessorProxy()
Virtual destructor. Disposes the wrapped accessor.
Definition: gmAccessorProxy.h:45
bool isScalar() const
Checks the dimType to see if the value is a scalar value. This cannot be infered by size() == 1 since...
Definition: gmValueInfo.h:180
GmAccessorProxy(GmValueAccessor *ac)
Constructor. Takes ownership of the accessor.
Definition: gmAccessorProxy.h:42
#define GMC_API_EXPORT
Macro for controling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_LI...
Definition: gmCoreConfig.h:35
Declaration of the GmValueAccessor interface and GmValueAccessorBase class.
double convertToAccessorUnit(double val) const
An utility function that given a value, converts it to the accessor unit. If no conversion is needed,...
Definition: gmAccessorProxy.h:58
Helper class with common code for several classes that wrap a value accessor, provinding a slitly dif...
Definition: gmAccessorProxy.h:38
void convertFromAccessorUnit(const double *val, double *dst) const
Copies the values given by val into the area pointed to by dst, converting units if needed.
Definition: gmAccessorProxy.h:70