bes  Updated for version 3.20.6
ncml_module::NetcdfElement Class Reference

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

#include <NetcdfElement.h>

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 = "netcdf"
 
static const std::vector< std::string > _sValidAttributes = getValidAttributes()
 

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!

Definition at line 340 of file NetcdfElement.cc.

◆ addPreDeleteCB()

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

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

Definition at line 127 of file RCObject.cc.

◆ 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.

Definition at line 476 of file NetcdfElement.cc.

◆ areAllAttributesValid()

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.

Definition at line 229 of file NCMLElement.cc.

◆ 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!

Definition at line 249 of file NetcdfElement.cc.

◆ clearDimensions()

void ncml_module::NetcdfElement::clearDimensions ( )

Clear the dimension table, releasing all strong references

Definition at line 366 of file NetcdfElement.cc.

◆ clone()

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.

Definition at line 115 of file NetcdfElement.cc.

◆ 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.

Definition at line 263 of file NetcdfElement.cc.

◆ 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.

Definition at line 640 of file NetcdfElement.cc.

◆ 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.

Definition at line 279 of file NetcdfElement.cc.

◆ 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.

Definition at line 419 of file NetcdfElement.cc.

◆ 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

Definition at line 457 of file NetcdfElement.cc.

◆ 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]

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.

Definition at line 207 of file NetcdfElement.cc.

◆ 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.

Definition at line 377 of file NetcdfElement.cc.

◆ 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.

Definition at line 326 of file NetcdfElement.cc.

◆ 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.

Definition at line 310 of file NetcdfElement.cc.

◆ 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.

Definition at line 237 of file NetcdfElement.cc.

◆ getParentAggregation()

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

Definition at line 408 of file NetcdfElement.cc.

◆ 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.

Definition at line 398 of file NetcdfElement.cc.

◆ getRefCount()

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

Get the current reference count

Implements agg_util::RCObjectInterface.

Definition at line 99 of file RCObject.cc.

◆ getTypeName()

const 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.

Definition at line 109 of file NetcdfElement.cc.

◆ handleBegin()

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.

Definition at line 139 of file NetcdfElement.cc.

◆ handleContent()

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.

Definition at line 159 of file NetcdfElement.cc.

◆ handleEnd()

void ncml_module::NetcdfElement::handleEnd ( )
virtual

Handle the closing of this element.

Implements ncml_module::NCMLElement.

Definition at line 168 of file NetcdfElement.cc.

◆ isCoordValueLexicographicallyLessThan()

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.

Definition at line 501 of file NetcdfElement.cc.

◆ isLocationLexicographicallyLessThan()

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.

Definition at line 491 of file NetcdfElement.cc.

◆ 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.

Definition at line 229 of file NetcdfElement.cc.

◆ isValidAttribute()

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

Definition at line 217 of file NCMLElement.cc.

◆ line()

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

Return the current parse line number. Shorthand

Definition at line 160 of file NCMLElement.cc.

◆ printAttributeIfNotEmpty()

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.

Definition at line 212 of file NCMLElement.cc.

◆ printDimensions()

string ncml_module::NetcdfElement::printDimensions ( ) const

"Print" out the dimensions to a string

Definition at line 354 of file NetcdfElement.cc.

◆ ref()

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.

Definition at line 69 of file RCObject.cc.

◆ removeFromPool()

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.

Definition at line 104 of file RCObject.cc.

◆ removePreDeleteCB()

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

Remove it exists. If not, this unchanged.

Definition at line 140 of file RCObject.cc.

◆ setAttributes()

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.

Definition at line 120 of file NetcdfElement.cc.

◆ 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.

Definition at line 382 of file NetcdfElement.cc.

◆ setParentAggregation()

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

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

Definition at line 413 of file NetcdfElement.cc.

◆ 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.

Definition at line 481 of file NetcdfElement.cc.

◆ toString()

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

Return a string describing the element

Implements ncml_module::NCMLElement.

Definition at line 196 of file NetcdfElement.cc.

◆ 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.

Definition at line 256 of file NetcdfElement.cc.

◆ unref()

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.

Definition at line 76 of file RCObject.cc.

◆ validateAttributes()

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

Definition at line 174 of file NCMLElement.cc.


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