GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
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{
40public:
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
54protected:
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 GmXdmfHdf5, GmHdf5ModelReader and GmHdf5ModelWriter to improve performance
74 friend class GmStateDump;
75 friend class GmXdmfHdf5;
76 friend class GmHdf5ModelWriter;
77 friend class GmHdf5ModelReader;
78
79 GmValueAccessor* _ac;
80};
81
82
83#endif
84
Helper class with common code for several classes that wrap a value accessor, provinding a slitly dif...
Definition gmAccessorProxy.h:39
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
virtual ~GmAccessorProxy()
Virtual destructor. Disposes the wrapped accessor.
Definition gmAccessorProxy.h:45
GmAccessorProxy(GmValueAccessor *ac)
Constructor. Takes ownership of the accessor.
Definition gmAccessorProxy.h:42
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
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
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
A helper class used to parse and retrieve data from am hdf5 model file. Used by the mesh plugin to re...
Definition gmHdf5ModelReader.h:53
A class used to export parts of a GeMA model to an HDF5 file. Its API includes both GeMA centric func...
Definition gmHdf5ModelWriter.h:58
The GmStateDump class presents a higher level of abstraction over GmMemoryDump, storing accessor data...
Definition gmStateDump.h:54
Interface class for accessing and setting values from an "indexable" collection of values.
Definition gmValueAccessor.h:60
Auxiliar class used to store the definition of a value. It can be used to store informations about st...
Definition gmValueInfo.h:132
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:190
A support class for saving data to a HDF5 file. Hdf5 files are self-describing but do not have a fixe...
Definition gmXdmfHdf5.h:71
#define GMC_API_EXPORT
Macro for controlling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_L...
Definition gmCoreConfig.h:35
Declaration of the GmValueAccessor interface and GmValueAccessorBase class.