Variable class. More...
#include <eoslib_var.h>
Public Member Functions | |
var (group *g, const std::string &name) | |
Constrictor. | |
var (group *g, const std::string &name, const std::string &orig_name) | |
virtual | ~var () |
Destructor. | |
std::list< dim * > & | get_dims () |
Getting dimensions. | |
const std::list< dim * > & | get_dims_c () const |
Getting dimensions (const). | |
bool | has_dim_of (dim *d) const |
Checking if this has dim. | |
std::vector< int32 > | get_dim_sizes () const |
std::list< attr * > & | get_attrs () |
Getting attributes. | |
const std::list< attr * > & | get_attrs_c () const |
Getting attributes (const). | |
attr * | get_attr_by_name (const std::string &name) |
Getting attributes by name. | |
void | set_cv () |
Setting current variable as a coordinate variable. | |
group * | get_group () const |
Getting the group where the current variable is. | |
virtual value_type_t | get_type () const =0 |
Getting variable type. | |
virtual void | get_value (int32 start[], int32 stride[], int32 edge[], void *buf) const =0 |
Getting a subset value. | |
void | get_all_values (std::vector< char > *pbuf) const |
Getting all values. | |
unsigned int | get_tot_num_elements () const |
Getting total number of elements. | |
unsigned int | get_tot_num_bytes () const |
Getting total number of bytes. | |
unsigned int | get_num_bytes (int32) const |
Getting actual number of bytes given the number of elements. | |
void | get_all (void **pbuf) |
get_all() allocates buffer which can hold all values, read all values, store them in the allocate buffer, and return the allocate buffer. | |
std::string | get_origname () const |
Getting the original name. This only happens when hybrid SDS/Vdata objects are added to an HDF-EOS2 file. | |
template<typename T > | |
T | get_item_at (const void *buf, const std::vector< int32 > &pos) |
Getting a specific element in the value array. | |
void | dump_r (int sp, bool bDumpValues=false) const |
Dumping variable to stdout. | |
void | add_attr (attr *a) |
Adding a new attribute. | |
void | remove_attr (attr *a) |
Removing an attribute. | |
bool | is_cv (group *g) |
Checking whether the current var is a coordinate varaible in the group g. | |
var * | clone_r (group *g, const std::map< dim *, dim * > &dimmap) const |
clone_r() internally calls _clone() to duplicae the current variable. | |
bool | is_equivalent_to (var *v) const |
This fuction compares two variables for equivalence. | |
virtual bool | same_obj_test (var *v) const =0 |
This function checks whether the current variable and another variable v are actually the same object in the file or not. | |
void | replace_all_dims (const std::map< dim *, dim * > &dimmap) |
Replacing dims. | |
Static Public Member Functions | |
static std::string | s_get_name (const var *v) |
Getting name. | |
static bool | s_same_obj_test (var *v1, var *v2) |
Checking whether two variables are the same object in the file. | |
static bool | s_same_objlist_test (const std::list< var * > &l1, const std::list< var * > &l2) |
Checking whether two list of variables are the same objs. | |
static int32 | INDEX_nD_TO_1D (const std::vector< int32 > &dims, const std::vector< int32 > &pos) |
Converting n-dim position to 1D position. | |
static int32 | INDEX_nD_TO_1D (int32 rank, const int32 dim[], const int32 pos[]) |
template<typename T > | |
static int | subset (const T input[], int32 rank, const int32 dim[], const int32 start[], const int32 stride[], const int32 edge[], std::vector< T > *poutput) |
Getting a subset of a variable. | |
template<typename T > | |
static int | subset2 (const T input[], int32 rank, int32 dim[], int32 start[], int32 stride[], int32 edge[], std::vector< T > *poutput, int32 pos[], int index) |
Getting a subset of a variable. | |
Protected Member Functions | |
var (const var &r) | |
void | _clone_attrs () |
For each attribute, this function clone it and replace the old attribute pointer to a new one. | |
virtual var * | _clone () const =0 |
_clone() makes another copy of the current variable. | |
Protected Attributes | |
group * | m_group |
std::list< dim * > | m_dims |
std::list< attr * > | m_attrs |
std::string | var_orig_name |
This class represents a variable (or data field).
virtual var* eoslib::var::_clone | ( | ) | const [protected, pure virtual] |
void eoslib::var::_clone_attrs | ( | ) | [protected] |
This is part of the variable cloning process.
var* eoslib::var::clone_r | ( | group * | g, | |
const std::map< dim *, dim * > & | dimmap | |||
) | const |
Since the duplicated var has the same dim pointers, attr pointers, and group pointer, we need to update them.
New group pointer: g New dim pointers: updated New attr pointers: new instances are created.
T eoslib::var::get_item_at | ( | const void * | buf, | |
const std::vector< int32 > & | pos | |||
) | [inline] |
This follows C-major convention. foo[1][2][3] -> vector of [1,2,3]
References get_dims_c().
bool eoslib::var::is_equivalent_to | ( | var * | v | ) | const |
Two vars are equivalent if they have equivalent dims (same order, same name, same size) they have same values they have equivalent attributes
Two objs are equivalent if they have the same value even if they do not occupy the same memory storage.
virtual bool eoslib::var::same_obj_test | ( | var * | v | ) | const [pure virtual] |
Since file handles are used for comparison, this is a quick process
void eoslib::var::set_cv | ( | ) |
This function sets the current var as a coordinate variable. This means that all dimensions of the current var has the current variable as the coordinate variable. Note that some dimenstions (lat/lon) may have more than one coordinate variables. This function appends the current variable to the list of coordinate variables in all its dimensions.
static int eoslib::var::subset | ( | const T | input[], | |
int32 | rank, | |||
const int32 | dim[], | |||
const int32 | start[], | |||
const int32 | stride[], | |||
const int32 | edge[], | |||
std::vector< T > * | poutput | |||
) | [inline, static] |
input | Input variable | |
dim | dimension info of the input | |
start | start indexes of each dim | |
stride | stride of each dim | |
edge | edge of each dim | |
poutput | output variable |
References INDEX_nD_TO_1D().
static int eoslib::var::subset2 | ( | const T | input[], | |
int32 | rank, | |||
int32 | dim[], | |||
int32 | start[], | |||
int32 | stride[], | |||
int32 | edge[], | |||
std::vector< T > * | poutput, | |||
int32 | pos[], | |||
int | index | |||
) | [inline, static] |
input | Input variable | |
dim | dimension info of the input | |
start | start indexes of each dim | |
stride | stride of each dim | |
edge | count of each dim | |
poutput | output variable index dimension index |
References INDEX_nD_TO_1D().