Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Static Protected Member Functions | List of all members
EncodingODIM Class Reference

Structure for data storage type, scaling and marker codes. Does not contain quantity. More...

#include <EncodingODIM.h>

Inheritance diagram for EncodingODIM:
Inheritance graph
[legend]
Collaboration diagram for EncodingODIM:
Collaboration graph
[legend]

Public Types

enum  ExplicitSetting { NONE =0 , SCALING =1 , RANGE =2 }
 
typedef ODIMPathElem::group_t group_t
 
- Public Types inherited from ReferenceMap
enum  extLinkPolicy { LINK , RESERVE , SKIP , ERROR }
 
typedef std::map< std::string, std::string > unitmap_t
 
- Public Types inherited from SmartMap< Reference >
typedef SmartMap< Referencesmap_t
 
typedef std::map< std::string, Referencemap_t
 
typedef map_t::key_type key_t
 
typedef map_t::mapped_type value_t
 
typedef map_t::value_type entry_t
 
typedef std::list< std::string > keylist_t
 
typedef map_t::iterator iterator
 Needed?
 
typedef map_t::const_iterator const_iterator
 

Public Member Functions

 EncodingODIM (group_t initialize=ODIMPathElem::ALL_LEVELS)
 Default constructor.
 
 EncodingODIM (const EncodingODIM &odim)
 Copy constructor.
 
 EncodingODIM (char type, double scale=1.0, double offset=0.0, double nodata=NAN, double undetect=NAN, const drain::Range< double > &range={0, 0})
 Scale driven encoding for brace inits. RISK: group_t confusion?
 
 EncodingODIM (char type, const drain::Range< double > &range, double scale=0.0, double offset=0.0, double nodata=NAN, double undetect=NAN)
 Range-driven encoding for brace inits.
 
 EncodingODIM (const drain::image::Image &image)
 
 EncodingODIM (drain::image::Image &image)
 
EncodingODIMoperator= (const EncodingODIM &odim)
 
 operator drain::ValueScaling & ()
 
 operator const drain::ValueScaling & () const
 
EncodingODIMsetScaling (double gain, double offset=NAN)
 
EncodingODIMsetScaling (double gain, double offset, double undetect, double nodata)
 
bool isSet () const
 
void setRange (double min, double max)
 
template<class T >
void setTypeDefaults (const T &type, const std::string &values="")
 Sets gain=1, offset=0, undetect=type_min, nodata=type_max. Note: sets type only if unset.
 
void setTypeDefaults ()
 
bool isValue (double x) const
 Returns true for a valid measurement value, false for undetect and nodata marker values.
 
double scaleForward (double x) const
 Converts a quantity from storage scale: y = offset + gain*y .
 
double scaleInverse (double y) const
 Converts a quantity to storage scale: x = (y-offset)/gain .
 
double getMin () const
 Returns the minimum physical value that can be returned using current storage type, gain and offset.
 
double getMax () const
 Returns the minimum physical value that can be returned using current storage type, gain and offset.
 
double operator() (double y) const
 Functor (why inverse?)
 
void clear ()
 Resets the values. More...
 
virtual void updateLenient (const EncodingODIM &odim)
 Todo: keep the function, but move implementation to (future single-exec) register ? More...
 
void grantShortKeys (drain::ReferenceMap &ref)
 Creates a short alias (attrib) for each (group):(attrib). Example: "gain" => "what:gain".
 
void addShortKeys ()
 Creates a short alias (attrib) for each (group):(attrib). Example: "gain" => "what:gain".
 
void copyFrom (const drain::image::Image &data)
 Copies image attributes and type . Experimental. More...
 
- Public Member Functions inherited from ReferenceMap
 ReferenceMap (char separator=',')
 Default constructor. More...
 
 ReferenceMap (const ReferenceMap &rmap)
 Copy constructor copies only the separators; does not copy the items. More...
 
template<class F >
Referencelink (const std::string &key, Range< F > &x, const std::string &unit=std::string())
 
template<class F >
Referencelink (const std::string &key, F &x, const std::string &unit=std::string())
 Associates a map entry with a variable. More...
 
Referencelink (const std::string &key, Reference &x, const std::string &unit=std::string())
 
Referencelink (const std::string &key, void *ptr, const std::type_info &type, size_t count, const std::string &unit=std::string())
 For arrays.
 
Referencelink (const std::string &key, void *ptr, const std::type_info &type, const std::string &unit=std::string())
 Convenience: create a reference to a scalar. For arrays, use the.
 
template<class F >
ReferencereferenceTop (const std::string &key, F &x, const std::string &unit=std::string())
 Associates a map entry with a variable, adding key in the beginning of key list. More...
 
void append (ReferenceMap &rMap, bool replace=true)
 Adopts the references of r. If replace==false, only new entries are appended.
 
void delink (const std::string &key)
 Removes an entry from the map.
 
void reserve (const std::string &key)
 Adds a null entry, expecting the link later. More...
 
template<class T >
void copyStruct (const ReferenceMap &m, const T &src, T &dst, extLinkPolicy policy=RESERVE)
 Experimental. Copies references and values of a structure to another. More...
 
template<class T >
ReferenceMapoperator= (const SmartMap< T > &v)
 Import map, adopting the element types.
 
virtual mapped_type & operator[] (const std::string &key)
 Return element associated with key.
 
virtual const mapped_type & operator[] (const std::string &key) const
 Calling unreferenced key throws an exception.
 
const unitmap_t & getUnitMap () const
 Returns measurement unit information of the actual map entries.
 
- Public Member Functions inherited from SmartMap< Reference >
 SmartMap (char separator='\0', char arraySeparator=':')
 
 SmartMap (const SmartMap &smap)
 
bool hasKey (const std::string &key) const
 
std::string get (const std::string &key, const std::string &defaultValue) const
 Retrieves a value, or default value if value is unset. More...
 
std::string get (const std::string &key, const char *defaultValue) const
 
T2 get (const std::string &key, const T2 &defaultValue) const
 Retrieves a value, if set, else returns the given default value. More...
 
virtual const keylist_t & getKeyList () const
 Derived versions may produce an ordered set of keys.
 
const map_t & getMap () const
 
void exportMap (std::map< std::string, T2 > &m) const
 Copies the contents to another map.
 
void importEntries (const std::string &entries, char assignmentSymbol='=', char separatorSymbol=0)
 Assigns a value to given key; if the entry does not exist, tries to create it with directly with operator[]. More...
 
void importEntries (const std::list< std::string > &entries, char assignmentSymbol='=')
 
void importMap (const std::map< std::string, S > &m)
 Assign values from a map, overriding existing entries. More...
 
void importCastableMap (const drain::SmartMap< T2 > &m)
 Assign values from a map, possibly extending the map. More...
 
void updateFromMap (const std::map< std::string, T2 > &m)
 Assign values from a map. Updates existing entries only. More...
 
void updateFromCastableMap (const drain::SmartMap< T2 > &m)
 Convenience.
 
void setValues (const std::string &entries, char assignmentSymbol='=', char separatorSymbol=0)
 Sets values. If strictness==STRICTLY_CLOSED, throws exception if tries to assign a non-existing entry.
 
void setValues (const char *entries, char assignmentSymbol='=', char separatorSymbol=0)
 
void setValuesSEQ (const S &sequence)
 
void updateValues (const std::string &entries, char assignmentSymbol='=', char separatorSymbol=0)
 Sets applicable values ie. modifies existing entries only. In ordered maps, skips extra entries silently.
 
void getKeys (std::ostream &ostr) const
 
std::string getKeys () const
 Convenience function for std::string output.
 
void getValues (std::ostream &ostr) const
 Dumps the values.
 
std::string getValues () const
 Convenience function for std::string output.
 
std::ostream & toStream (std::ostream &ostr, char equal='=', char startChar='{', char endChar='}', char separatorChar=',') const
 Note: parameters discarded.
 
std::string toStr (char equal='=', char start=0, char end=0, char separator=0) const
 
void dump (std::ostream &ostr=std::cout) const
 Write map as a JSON code. More...
 

Static Public Member Functions

static bool haveSimilarEncoding (const EncodingODIM &odim1, const EncodingODIM &odim2)
 Checks if data encoding is similar (storage type, gain, offset, undetect and nodata are the same).
 
static void checkType (Hi5Tree &dst)
 Traverses recursively subtrees and checks the types of PolarODIM variables. More...
 

Public Attributes

drain::ValueScalingscaling
 
const drain::ValueScalingscalingConst
 
drain::ValueScaling ownScaling
 
int explicitSettings
 
std::string type
 This is non-standard (not in ODIM), but a practical means of handling storage type of datasets. More...
 
double nodata
 data[n]/what (obligatory)
 
double undetect
 
- Public Attributes inherited from SmartMap< Reference >
char separator
 Default character used for splitting input and output. See setValues.
 
char arraySeparator
 Default separator character for array elements (std::vector's)
 

Static Public Attributes

static const drain::FlagResolver::dict_t settingDict
 
static const ODIMPathElemSeq & attributeGroups
 Copies contents of this to a h5 group. More...
 

Static Protected Member Functions

static void checkType (Hi5Tree &dst, EncodingODIM &odim)
 
static const ODIMPathElemSeq & getAttributeGroups ()
 

Additional Inherited Members

- Protected Attributes inherited from ReferenceMap
unitmap_t unitMap
 Creating a common segment for. More...
 
- Protected Attributes inherited from SmartMap< Reference >
std::list< std::string > keyList
 Assigns values from std::string of type "value,value2,...valueN". More...
 

Detailed Description

Structure for data storage type, scaling and marker codes. Does not contain quantity.

Within each ODIM class, each variable should have

  1. name
  2. type
  3. group/name
  4. dataset/group/name

The scope for variables extends "down to the data array". Ie.

Common interface:

  1. operator[](toStr)
  1. native variables (double, long int, std::string)

Typically used in creating and writing a product.

See also: LinearScaling (could be used as base class?)

Member Function Documentation

◆ checkType() [1/2]

static void checkType ( Hi5Tree &  dst)
inlinestatic

Traverses recursively subtrees and checks the types of PolarODIM variables.

Parameters
dst- start group

◆ checkType() [2/2]

void checkType ( Hi5Tree &  dst,
EncodingODIM odim 
)
staticprotected

Determine if it is ATTRIBUTE at root or PATH:ATTRIBUTE

◆ clear()

void clear ( )
virtual

Resets the values.

FIX rename !!

Reimplemented from ReferenceMap.

◆ copyFrom()

void copyFrom ( const drain::image::Image data)

Copies image attributes and type . Experimental.

Image storage type, "type", is a non-standard property that must be copied separately.

◆ updateLenient()

void updateLenient ( const EncodingODIM odim)
virtual

Todo: keep the function, but move implementation to (future single-exec) register ?

Sets type, if unset (empty).

Member Data Documentation

◆ attributeGroups

const ODIMPathElemSeq & attributeGroups
static

Copies contents of this to a h5 group.

Parameters
dstGroup- target group under which the respective /what , /where , and /how groups will be populated directly.

Currently, uses direct sub groups only, which means that subgroups referring to /dataset??/data??/data are used only.

Todo:
Change "what:quantity" -style namings to "dataset:data:what:quantity" .

dataset1/data1/quality1 A set containing "what", "where" and "how".

◆ settingDict

const drain::FlagResolver::dict_t settingDict
static
Initial value:
= {
{"NONE", NONE},
{"SCALING", SCALING},
{"RANGE", RANGE}
}

◆ type

std::string type

This is non-standard (not in ODIM), but a practical means of handling storage type of datasets.

See drain::Type.


The documentation for this class was generated from the following files: