bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
ncml_module::NetcdfElement Class Reference

Concrete class for NcML <netcdf> element. More...

#include <NetcdfElement.h>

Inheritance diagram for ncml_module::NetcdfElement:
Inheritance graph
Collaboration diagram for ncml_module::NetcdfElement:
Collaboration graph

Classes

class  VariableValueValidator
 

Public Member Functions

void addDimension (DimensionElement *dim)
 
void addPreDeleteCB (UseCountHitZeroCB *pCB)
 
void addVariableToValidateOnClose (libdap::BaseType *pNewVar, VariableElement *pVE)
 
void borrowResponseObject (BESDapResponse *pResponse)
 
void clearDimensions ()
 
virtual NetcdfElementclone () const
 
const std::string & coordValue () const
 
void createResponseObject (agg_util::DDSLoader::ResponseType type)
 
VariableElementfindVariableElementForLibdapVar (libdap::BaseType *pNewVar)
 
RCPtr< agg_util::AggMemberDatasetgetAggMemberDataset () const
 
AggregationElementgetChildAggregation () const
 
bool getCoordValueAsDouble (double &val) const
 
virtual libdap::DDS * getDDS ()
 
virtual const libdap::DDS * getDDS () const
 
const std::vector< DimensionElement * > & getDimensionElements () const
 
const DimensionElementgetDimensionInFullScope (const std::string &name) const
 
const DimensionElementgetDimensionInLocalScope (const std::string &name) const
 
unsigned int getNcoordsAsUnsignedInt () const
 
AggregationElementgetParentAggregation () const
 
NetcdfElementgetParentDataset () const
 
bool getProcessedMetadataDirective () const
 
virtual int getRefCount () const
 
virtual const std::string & getTypeName () const
 
virtual void handleBegin ()
 
virtual void handleContent (const std::string &content)
 
virtual void handleEnd ()
 
bool hasNcoords () const
 
const std::string & id () const
 
bool isValid () const
 
int line () const
 
const std::string & location () const
 
const std::string & ncoords () const
 
 NetcdfElement (const NetcdfElement &proto)
 
std::string printDimensions () const
 
virtual int ref () const
 
virtual void removeFromPool () const
 
void removePreDeleteCB (UseCountHitZeroCB *pCB)
 
virtual void setAttributes (const XMLAttributeMap &attrs)
 
void setChildAggregation (AggregationElement *agg, bool throwIfExists=true)
 
void setParentAggregation (AggregationElement *parent)
 
void setParser (NCMLParser *p)
 
void setProcessedMetadataDirective ()
 
void setVariableGotValues (libdap::BaseType *pVarToValidate, bool removeEntry)
 
const std::string & title () const
 
virtual std::string toString () const
 
void unborrowResponseObject (BESDapResponse *pResponse)
 
virtual int unref () const
 
virtual bool validateAttributes (const XMLAttributeMap &attrs, const std::vector< std::string > &validAttrs, std::vector< std::string > *pInvalidAttrs=0, bool printInvalid=true, bool throwOnError=true)
 

Static Public Member Functions

static bool areAllAttributesValid (const XMLAttributeMap &attrMap, const std::vector< std::string > &validAttrs, std::vector< std::string > *pInvalidAttributes=0)
 
static bool isCoordValueLexicographicallyLessThan (const NetcdfElement *pLHS, const NetcdfElement *pRHS)
 
static bool isLocationLexicographicallyLessThan (const NetcdfElement *pLHS, const NetcdfElement *pRHS)
 
static bool isValidAttribute (const std::vector< std::string > &validAttrs, const std::string &attr)
 
static std::string printAttributeIfNotEmpty (const std::string &attrName, const std::string &attrValue)
 

Static Public Attributes

static const std::string _sTypeName
 
static const std::vector< std::string > _sValidAttributes
 

Protected Attributes

NCMLParser_parser
 

Detailed Description

Concrete class for NcML <netcdf> element.

This element specifies the location attribute for the local data file that we wrap and load into a DDX (DDS w/ AttrTable tree).

We keep a ptr to our containing NCMLParser to help with the differences needed if we are the root dataset element or not, in particular that the response object is either passed in to us (root) or loaded brandy new if we're the child of an aggregation.

Definition at line 62 of file NetcdfElement.h.

Member Function Documentation

◆ addDimension()

void ncml_module::NetcdfElement::addDimension ( DimensionElement * dim)

Add the given element to this scope. We maintain a strong reference, so the caller should respect the RCObject count and not delete it on us!

◆ addPreDeleteCB()

void agg_util::RCObject::addPreDeleteCB ( UseCountHitZeroCB * pCB)
inherited

Add uniquely. If it is added agan, the second time is ignored.

◆ addVariableToValidateOnClose()

void ncml_module::NetcdfElement::addVariableToValidateOnClose ( libdap::BaseType * pNewVar,
VariableElement * pVE )

Add the pNewvar created by pVE to this dataset's list of variables to validate for having values set upon closing (handleEnd() of this element). All new variables are required to have values at the time the dataset is closed or a parse error is thrown at that time.

Parameters
pNewVarthe new variable to watch, used as a key to find pVE later
pVEthe variable element that created the pNewVar, which contains whether the value of pNewVar has been set yet (since there's no direct way in BaseType to do that now). pVE->ref() will be called to keep pVE around sicne it will go out of scope after this call. On the ~NetcdfElement, pVE->unref() will be called to undo this.

◆ areAllAttributesValid()

static bool ncml_module::NCMLElement::areAllAttributesValid ( const XMLAttributeMap & attrMap,
const std::vector< std::string > & validAttrs,
std::vector< std::string > * pInvalidAttributes = 0 )
staticinherited
Returns
whether all the attributes in attrMap are in validAttrs. If pInvalidAttributes, fill it in with all the illegal attributes.

◆ borrowResponseObject()

void ncml_module::NetcdfElement::borrowResponseObject ( BESDapResponse * pResponse)

Used by the NCMLParser to let us know to borrow the response object and not own it. Used for the root element only! Nested datasets will create and own their own!

◆ clearDimensions()

void ncml_module::NetcdfElement::clearDimensions ( )

Clear the dimension table, releasing all strong references

◆ clone()

virtual NetcdfElement * ncml_module::NetcdfElement::clone ( ) const
virtual

Make and return a copy of this. Used by the factory from a prototype.

Implements ncml_module::NCMLElement.

◆ coordValue()

const std::string & ncml_module::NetcdfElement::coordValue ( ) const
inline

Definition at line 97 of file NetcdfElement.h.

◆ createResponseObject()

void ncml_module::NetcdfElement::createResponseObject ( agg_util::DDSLoader::ResponseType type)

Called if this is a member of an aggregation (i.e. not root) to create a dynamic response object of the given type. This call or borrowResponseObject() must be called before this is used.

◆ findVariableElementForLibdapVar()

VariableElement * ncml_module::NetcdfElement::findVariableElementForLibdapVar ( libdap::BaseType * pNewVar)

If a VariableElement has been associated with a new var to validate, return it. If not, return null.

Parameters
pNewVarthe libdap variable (key) to look up
Returns
the associated VariableElement for pNewVar, else null if not set with addVariableToValidate.

◆ getAggMemberDataset()

RCPtr< agg_util::AggMemberDataset > ncml_module::NetcdfElement::getAggMemberDataset ( ) const

Return a shared reference to the AggMemberDataset that encapsulates this dataset. If it doesn't exist in this instance yet, it is created and stored in this (semantically const accessor) If it does exist, a shared reference to the contained object is returned.

◆ getChildAggregation()

AggregationElement * ncml_module::NetcdfElement::getChildAggregation ( ) const

Return the raw pointer (or NULL) to our contained aggregation. Only guaranteed valid for the life of this object.

◆ getCoordValueAsDouble()

bool ncml_module::NetcdfElement::getCoordValueAsDouble ( double & val) const

Parse the netcdf@coordValue attribute as a double. If successful, put the value in val and return true. If unsuccessful, val is unchanged and false is returned. ASSUMES: there is only ONE token in the coordValue field. TODO: look into loading multiple values later as needed.

Parameters
valoutput the parsed value here if possible
Returns
whether the parse was successful

◆ getDDS() [1/2]

virtual libdap::DDS * ncml_module::NetcdfElement::getDDS ( )
virtual

Non-const version to allow changes to the DDS. Do NOT delete the return value!

◆ getDDS() [2/2]

virtual const libdap::DDS * ncml_module::NetcdfElement::getDDS ( ) const
virtual

Return the DDS for this dataset, loading it in if needed. (semantically const although the loaded DDS is cached).

Implements agg_util::DDSAccessInterface.

◆ getDimensionElements()

const std::vector< DimensionElement * > & ncml_module::NetcdfElement::getDimensionElements ( ) const

Get the list of dimension elements local to only this dataset, not its enclosing scope.

◆ getDimensionInFullScope()

const DimensionElement * ncml_module::NetcdfElement::getDimensionInFullScope ( const std::string & name) const
Returns
the first DimensionElement with name found by checking getDimensionInLocalScope() starting at this element and traversing upwards to the enclosing scopes (in case we're in an aggregation). Return NULL if not found. @Note this allows dimensions to be lexically "shadowed". @Note Ultimately, shared dimensions cannot be shadowed, so we will need to make sure of this when we handle shared dimensions.

◆ getDimensionInLocalScope()

const DimensionElement * ncml_module::NetcdfElement::getDimensionInLocalScope ( const std::string & name) const
Returns
the DimensionElement with the given name in the dimension table for THIS NetcdfElement only (no traversing up the tree is allowed). If not found, NULL is returned.

◆ getNcoordsAsUnsignedInt()

unsigned int ncml_module::NetcdfElement::getNcoordsAsUnsignedInt ( ) const

Get the ncoords() field as a valid size. Throws: if !hasNCoords().

Returns
the parsed value of the ncoords() field.

◆ getParentAggregation()

AggregationElement * ncml_module::NetcdfElement::getParentAggregation ( ) const
Returns
the AggregationElement that contains me, or NULL if we're root.

◆ getParentDataset()

NetcdfElement * ncml_module::NetcdfElement::getParentDataset ( ) const

Return the next enclosing dataset for this, or NULL if we're the root. Basically traverse upwards through any aggregation parent to get containing datset.

◆ getProcessedMetadataDirective()

bool ncml_module::NetcdfElement::getProcessedMetadataDirective ( ) const
inline

Definition at line 136 of file NetcdfElement.h.

◆ getRefCount()

virtual int agg_util::RCObject::getRefCount ( ) const
virtualinherited

Get the current reference count

Implements agg_util::RCObjectInterface.

◆ getTypeName()

virtual const std::string & ncml_module::NetcdfElement::getTypeName ( ) const
virtual

Return the type of the element, which should be: the same as ConcreteClassName::getTypeName()

Implements ncml_module::NCMLElement.

◆ handleBegin()

virtual void ncml_module::NetcdfElement::handleBegin ( )
virtual

Handle a begin on this element. Called after creation and it is assumed the attributes and _parser are already set.

Implements ncml_module::NCMLElement.

◆ handleContent()

virtual void ncml_module::NetcdfElement::handleContent ( const std::string & content)
virtual

Handle the characters content for the element. Default impl throws if the content is not all whitespace. Subclasses that handle non-whitespace content should override.

Parameters
contentthe string of characters in the element content.

Reimplemented from ncml_module::NCMLElement.

◆ handleEnd()

virtual void ncml_module::NetcdfElement::handleEnd ( )
virtual

Handle the closing of this element.

Implements ncml_module::NCMLElement.

◆ hasNcoords()

bool ncml_module::NetcdfElement::hasNcoords ( ) const
inline

Definition at line 106 of file NetcdfElement.h.

◆ id()

const std::string & ncml_module::NetcdfElement::id ( ) const
inline

Definition at line 89 of file NetcdfElement.h.

◆ isCoordValueLexicographicallyLessThan()

static bool ncml_module::NetcdfElement::isCoordValueLexicographicallyLessThan ( const NetcdfElement * pLHS,
const NetcdfElement * pRHS )
static

Compare the coordvalue fields of the two arguments and return true if lhs.coordValue() < rhs.coordValue() in a lexicographic string sense. Used for std::sort on vector<NetcdfElement*>

See also
isLocationLexicographicallyLessThan()
Parameters
pLHSthe lefthandside of the less than Must not be null!
pRHSthe righthandside of the less than Must not be null!
Returns
if pLHS->coordValue() < pRHS->coordValue() lexicographically.

◆ isLocationLexicographicallyLessThan()

static bool ncml_module::NetcdfElement::isLocationLexicographicallyLessThan ( const NetcdfElement * pLHS,
const NetcdfElement * pRHS )
static

Compare the location fields of the two arguments and return true if lhs.location() < rhs.location() in a lexicographic string sense. Used for std::sort on vector<NetcdfElement*>

See also
isCoordValueLexicographicallyLessThan()
Parameters
pLHSthe lefthandside of the less than must not be null!
pRHSthe righthandside of the less than must not be null!
Returns
if pLHS->location() < pRHS->location() lexicographically.

◆ isValid()

bool ncml_module::NetcdfElement::isValid ( ) const
Returns
whether this is initialized properly and ready to be used. It should be true after handleBegin() if all is well.

◆ isValidAttribute()

static bool ncml_module::NCMLElement::isValidAttribute ( const std::vector< std::string > & validAttrs,
const std::string & attr )
staticinherited
Returns
whether the given attr is in the array validAttrs or not... Helper for subclasses

◆ line()

int ncml_module::NCMLElement::line ( ) const
inherited

Return the current parse line number. Shorthand

◆ location()

const std::string & ncml_module::NetcdfElement::location ( ) const
inline

Definition at line 85 of file NetcdfElement.h.

◆ ncoords()

const std::string & ncml_module::NetcdfElement::ncoords ( ) const
inline

Definition at line 101 of file NetcdfElement.h.

◆ printAttributeIfNotEmpty()

static std::string ncml_module::NCMLElement::printAttributeIfNotEmpty ( const std::string & attrName,
const std::string & attrValue )
staticinherited

Helper for subclasses implementing toString().

Returns
a string with attrName="attrValue" if !attrValue.empty(), otherwise return the empty string.

◆ printDimensions()

std::string ncml_module::NetcdfElement::printDimensions ( ) const

"Print" out the dimensions to a string

◆ ref()

virtual int agg_util::RCObject::ref ( ) const
virtualinherited

Increase the reference count by one. const since we do not consider the ref count part of the semantic constness of the rep

Implements agg_util::RCObjectInterface.

◆ removeFromPool()

virtual void agg_util::RCObject::removeFromPool ( ) const
virtualinherited

If the object is in an auto-delete pool, remove it from the pool and force it to only delete when it's ref count goes to 0. Useful when we desire a particular object stay around outside of the pool's lifetime.

Implements agg_util::RCObjectInterface.

◆ removePreDeleteCB()

void agg_util::RCObject::removePreDeleteCB ( UseCountHitZeroCB * pCB)
inherited

Remove it exists. If not, this unchanged.

◆ setAttributes()

virtual void ncml_module::NetcdfElement::setAttributes ( const XMLAttributeMap & attrs)
virtual

Set the attributes of this from the map.

Parameters
attrsthe attribute map to set this class to.

Implements ncml_module::NCMLElement.

◆ setChildAggregation()

void ncml_module::NetcdfElement::setChildAggregation ( AggregationElement * agg,
bool throwIfExists = true )

Set our aggregation to the given agg.

If there exists an aggregation already and !throwIfExists, agg will replace it, which might cause the previous one to be deleted.

If there exists one already and agg != NULL and throwIfExists, an exception will be thrown.

If agg == NULL, it always removes the strong reference to the previous, regardless of throwIfExists.

◆ setParentAggregation()

void ncml_module::NetcdfElement::setParentAggregation ( AggregationElement * parent)

Set my parent AggregationElement to parent. This is a weak reference.

◆ setProcessedMetadataDirective()

void ncml_module::NetcdfElement::setProcessedMetadataDirective ( )
inline

Definition at line 141 of file NetcdfElement.h.

◆ setVariableGotValues()

void ncml_module::NetcdfElement::setVariableGotValues ( libdap::BaseType * pVarToValidate,
bool removeEntry )

Lookup the VariableElement* associated with pVarToValidate via a previous addVariableToValidateOnClose() and call pVE->setGotValues() on the associated element so that it will be considered valid at handleEnd() of this element. Should be called when the values are set on pVarToValidate.

Parameters
pVarToValidatethe variable which has had its deferred values set to be used as a key to lookup the associated VariableElement that created it.
removeEntryif the entry is found, remove it from the list as well as setting gotvalues.

◆ title()

const std::string & ncml_module::NetcdfElement::title ( ) const
inline

Definition at line 93 of file NetcdfElement.h.

◆ toString()

virtual std::string ncml_module::NetcdfElement::toString ( ) const
virtual

Return a string describing the element

Implements ncml_module::NCMLElement.

◆ unborrowResponseObject()

void ncml_module::NetcdfElement::unborrowResponseObject ( BESDapResponse * pResponse)

Kind of superfluous, but tells this object to clear its reference to pReponse, which had better match _response or we throw internal exception.

◆ unref()

virtual int agg_util::RCObject::unref ( ) const
virtualinherited

Decrease the reference count by one. If it goes from 1 to 0, delete this and this is no longer valid.

Returns
the new ref count. If it is 0, the caller knows the object was deleted.

It is illegal to unref() an object with a count of 0. We don't throw to allow use in dtors, so the caller is assumed not to do it!

const since the reference count is not part of the semantic constness of the rep

Implements agg_util::RCObjectInterface.

◆ validateAttributes()

virtual bool ncml_module::NCMLElement::validateAttributes ( const XMLAttributeMap & attrs,
const std::vector< std::string > & validAttrs,
std::vector< std::string > * pInvalidAttrs = 0,
bool printInvalid = true,
bool throwOnError = true )
virtualinherited

Check that the given attributes are all in the valid set, otherwise fill in *pInvalidAttrs with the problematic ones if it's not null. If pInvalidAttrs && printInvalid is set, we print the problematic attributes to BESDEBUG "ncml" channel If throwOnError is set, we throw a parse error instead of returning.

Returns
whether all attributes are in the valid set if not throw

Member Data Documentation

◆ _parser

NCMLParser* ncml_module::NCMLElement::_parser
protectedinherited

Definition at line 187 of file NCMLElement.h.

◆ _sTypeName

const std::string ncml_module::NetcdfElement::_sTypeName
static

Definition at line 69 of file NetcdfElement.h.

◆ _sValidAttributes

const std::vector<std::string> ncml_module::NetcdfElement::_sValidAttributes
static

Definition at line 70 of file NetcdfElement.h.


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