VAPOR3 3.9.4
DCRAM.h
Go to the documentation of this file.
1#include <vector>
2#include <algorithm>
3#include <map>
4#include <iostream>
5#include <vapor/MyBase.h>
7#include <vapor/Proj4API.h>
9#include <vapor/utils.h>
10#include <vapor/DC.h>
11#include <vapor/STLUtils.h>
12
13#pragma once
14
15namespace VAPoR {
16
17
21
22class VDF_API DCRAM : public VAPoR::DC {
23public:
25 virtual ~DCRAM();
26
27 void Test();
28
29 void AddDimension(const DC::Dimension &dim);
30 void AddMesh(const DC::Mesh &mesh);
31 void AddCoordVar(const DC::CoordVar &var, const float *buf);
32 void AddDataVar(const DC::DataVar &var, const float *buf);
33
34protected:
35 map<string, float*> _dataMap;
36
37 void copyVarData(const DC::BaseVar &var, const float *buf, const size_t size);
38
41 virtual int initialize(const vector<string> &paths, const std::vector<string> &options);
42
43
46 virtual bool getDimension(string dimname, DC::Dimension &dimension) const;
47 virtual bool getDimension(string dimname, DC::Dimension &dimension, long ts) const;
48
51 virtual std::vector<string> getDimensionNames() const;
52
55 std::vector<string> getMeshNames() const;
56
59 virtual bool getMesh(string mesh_name, DC::Mesh &mesh) const;
60
63 virtual bool getCoordVarInfo(string varname, DC::CoordVar &cvar) const;
64
67 virtual bool getDataVarInfo(string varname, DC::DataVar &datavar) const;
68
71 virtual bool getAuxVarInfo(string varname, DC::AuxVar &var) const;
72
73
75 //
76 virtual bool getBaseVarInfo(string varname, DC::BaseVar &var) const;
77
78
79
82 virtual std::vector<string> getDataVarNames() const;
83
84 virtual std::vector<string> getAuxVarNames() const;
85
86
89 virtual std::vector<string> getCoordVarNames() const;
90
93 virtual size_t getNumRefLevels(string varname) const { return (1); }
94
97 virtual string getMapProjection() const
98 {
99 return "";
100 }
101
104 virtual bool getAtt(string varname, string attname, vector<double> &values) const;
105 virtual bool getAtt(string varname, string attname, vector<long> &values) const;
106 virtual bool getAtt(string varname, string attname, string &values) const;
107
110 virtual std::vector<string> getAttNames(string varname) const;
111
114 virtual XType getAttType(string varname, string attname) const;
115
118 virtual int getDimLensAtLevel(string varname, int level, std::vector<size_t> &dims_at_level, std::vector<size_t> &bs_at_level) const;
119 virtual int getDimLensAtLevel(string varname, int level, std::vector<size_t> &dims_at_level, std::vector<size_t> &bs_at_level, long ts) const;
120
121
124 virtual int openVariableRead(size_t ts, string varname, int, int) { return (DCRAM::openVariableRead(ts, varname)); }
125
126 virtual int openVariableRead(size_t ts, string varname);
127
128
131 virtual int closeVariable(int fd);
132
134 //
135 virtual int readRegion(int fd, const vector<size_t> &min, const vector<size_t> &max, float *region) { return (_readRegionTemplate(fd, min, max, region)); }
136 virtual int readRegion(int fd, const vector<size_t> &min, const vector<size_t> &max, int *region) { return (_readRegionTemplate(fd, min, max, region)); }
137 virtual int readRegion(int fd, const vector<size_t> &min, const vector<size_t> &max, double *region) { VAssert(!"DCRAM: double data not supported"); return -1; }
138
141 virtual int readRegionBlock(int fd, const vector<size_t> &min, const vector<size_t> &max, float *region) { return (_readRegionTemplate(fd, min, max, region)); };
142 virtual int readRegionBlock(int fd, const vector<size_t> &min, const vector<size_t> &max, int *region) { return (_readRegionTemplate(fd, min, max, region)); }
143 virtual int readRegionBlock(int fd, const vector<size_t> &min, const vector<size_t> &max, double *region) { VAssert(!"DCRAM: double data not supported"); return -1; }
144
147 virtual bool variableExists(size_t ts, string varname, int reflevel = 0, int lod = 0) const;
148
149private:
150 std::map<string, DC::Dimension> _dimsMap;
151 std::map<string, DC::CoordVar> _coordVarsMap;
152 std::map<string, DC::AuxVar> _auxVarsMap;
153 std::map<string, DC::Mesh> _meshMap;
154 std::map<string, DC::DataVar> _dataVarsMap;
155
156 int _fakeVarsFileCounterStart = 10000;
157 int _fakeVarsFileCounter = _fakeVarsFileCounterStart;
158 std::map<int, string> _fdMap;
159
160
161 template<class T> int _readRegionTemplate(int fd, const vector<size_t> &min, const vector<size_t> &max, T *region);
162
163 template<class T> bool _getAttTemplate(string varname, string attname, T &values) const;
164};
165}; // namespace VAPoR
#define VAssert(expr)
Definition: VAssert.h:9
DCRAM is a virtual data collection used to allow data to be loaded from ram. Specifically,...
Definition: DCRAM.h:22
virtual int readRegion(int fd, const vector< size_t > &min, const vector< size_t > &max, int *region)
Definition: DCRAM.h:136
virtual string getMapProjection() const
Definition: DCRAM.h:97
virtual bool getMesh(string mesh_name, DC::Mesh &mesh) const
virtual bool getDimension(string dimname, DC::Dimension &dimension, long ts) const
virtual ~DCRAM()
virtual bool getDimension(string dimname, DC::Dimension &dimension) const
virtual std::vector< string > getAuxVarNames() const
virtual bool getAtt(string varname, string attname, vector< double > &values) const
virtual int readRegionBlock(int fd, const vector< size_t > &min, const vector< size_t > &max, double *region)
Definition: DCRAM.h:143
virtual int readRegionBlock(int fd, const vector< size_t > &min, const vector< size_t > &max, float *region)
Definition: DCRAM.h:141
virtual int openVariableRead(size_t ts, string varname, int, int)
Definition: DCRAM.h:124
map< string, float * > _dataMap
Definition: DCRAM.h:35
virtual size_t getNumRefLevels(string varname) const
Definition: DCRAM.h:93
virtual int readRegionBlock(int fd, const vector< size_t > &min, const vector< size_t > &max, int *region)
Definition: DCRAM.h:142
virtual bool getAtt(string varname, string attname, vector< long > &values) const
virtual int readRegion(int fd, const vector< size_t > &min, const vector< size_t > &max, double *region)
Definition: DCRAM.h:137
virtual int initialize(const vector< string > &paths, const std::vector< string > &options)
virtual int getDimLensAtLevel(string varname, int level, std::vector< size_t > &dims_at_level, std::vector< size_t > &bs_at_level) const
virtual bool getAtt(string varname, string attname, string &values) const
std::vector< string > getMeshNames() const
virtual bool getAuxVarInfo(string varname, DC::AuxVar &var) const
virtual std::vector< string > getCoordVarNames() const
virtual std::vector< string > getAttNames(string varname) const
virtual bool getCoordVarInfo(string varname, DC::CoordVar &cvar) const
void AddMesh(const DC::Mesh &mesh)
void copyVarData(const DC::BaseVar &var, const float *buf, const size_t size)
virtual bool getDataVarInfo(string varname, DC::DataVar &datavar) const
virtual int readRegion(int fd, const vector< size_t > &min, const vector< size_t > &max, float *region)
Definition: DCRAM.h:135
void AddCoordVar(const DC::CoordVar &var, const float *buf)
virtual std::vector< string > getDimensionNames() const
virtual bool getBaseVarInfo(string varname, DC::BaseVar &var) const
virtual int closeVariable(int fd)
void AddDataVar(const DC::DataVar &var, const float *buf)
virtual int openVariableRead(size_t ts, string varname)
virtual int getDimLensAtLevel(string varname, int level, std::vector< size_t > &dims_at_level, std::vector< size_t > &bs_at_level, long ts) const
void AddDimension(const DC::Dimension &dim)
virtual std::vector< string > getDataVarNames() const
virtual XType getAttType(string varname, string attname) const
virtual bool variableExists(size_t ts, string varname, int reflevel=0, int lod=0) const
Auxiliary variable metadata.
Definition: DC.h:1230
Base class for storing variable metadata.
Definition: DC.h:754
Coordinate variable metadata.
Definition: DC.h:881
Data variable metadata.
Definition: DC.h:987
Metadata describing a named dimension length.
Definition: DC.h:163
Metadata describing a computational mesh.
Definition: DC.h:310
A Template Method design pattern for reading a collection of data.
Definition: DC.h:150
XType
External storage types for primitive data.
Definition: DC.h:154
#define VDF_API
Definition: common.h:73