nidas v1.2.3
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
nidas::core::Project Class Reference

#include <Project.h>

Inheritance diagram for nidas::core::Project:
Inheritance graph
[legend]

Classes

class  MyDictionary
 

Public Member Functions

 Project ()
 
virtual ~Project ()
 
void parseXMLConfigFile (const std::string &xmlfilepath)
 Convenient method to fill this Project instance from the configuration in the XML file at xmlfilepath, using the nidas::core::parseXMLConfigFile() function.
 
void setName (const std::string &val)
 
const std::string & getName () const
 
void setSystemName (const std::string &val)
 
const std::string & getSystemName () const
 
void setConfigVersion (const std::string &val)
 
const std::string & getConfigVersion () const
 
void setConfigName (const std::string &val)
 
const std::string & getConfigName () const
 
void setFlightName (const std::string &val)
 
const std::string & getFlightName () const
 
void addSite (Site *val)
 
const std::list< Site * > & getSites () const
 
int getMaxSiteNumber () const
 Convenience function to return the maximum site number.
 
int getMinSiteNumber () const
 
void addServer (DSMServer *srvr)
 A Project has one or more DSMServers.
 
const std::list< DSMServer * > & getServers () const
 
std::list< DSMServer * > findServers (const std::string &hostname) const
 Look for a server for this project that either has no name or whose name matches hostname.
 
DSMServerfindServer (const nidas::util::Inet4Address &addr) const
 
const DSMConfigfindDSM (const nidas::util::Inet4Address &addr) const
 Find a DSM whose name corresponds to a given IP address.
 
const DSMConfigfindDSM (const std::string &name) const
 Find a DSMConfig in any site in this project whose name matches the given hostname.
 
const DSMConfigfindDSM (unsigned int id) const
 Find a DSM matching id;.
 
std::list< nidas::core::FileSet * > findServerSampleOutputStreamFileSets (const std::string &name) const
 Find SampleOutputStreamFileSets belonging to SampleArchivers of DSMServers whose name matches the argument name.
 
std::list< nidas::core::FileSet * > findServerSampleOutputStreamFileSets () const
 Call findServerSampleOutputStreamFileSets(name) passing the nodename returned by uname(2).
 
std::list< nidas::core::FileSet * > findSampleOutputStreamFileSets (const std::string &dsmName) const
 Find SampleOutputStreamFileSets belonging to the given DSM.
 
std::list< nidas::core::FileSet * > findSampleOutputStreamFileSets () const
 Find SampleOutputStreamFileSets of all DSMs.
 
DSMSensorfindSensor (dsm_sample_id_t id) const
 
DSMSensorfindSensor (const SampleTag *tag) const
 
SitefindSite (int stationNumber) const
 Find a Site with the given station number.
 
SitefindSite (const std::string &name) const
 Find a Site with the given name.
 
dsm_sample_id_t getUniqueSampleId (unsigned int dsmid)
 Get a temporary unique sample id for a given DSM id.
 
void setSensorCatalog (SensorCatalog *val)
 
SensorCataloggetSensorCatalog () const
 
void setDSMCatalog (DSMCatalog *val)
 
DSMCataloggetDSMCatalog () const
 
void setServiceCatalog (ServiceCatalog *val)
 
ServiceCataloggetServiceCatalog () const
 
DSMServerIterator getDSMServerIterator () const
 
DSMServiceIterator getDSMServiceIterator () const
 
ProcessorIterator getProcessorIterator () const
 
SiteIterator getSiteIterator () const
 
DSMConfigIterator getDSMConfigIterator () const
 
SensorIterator getSensorIterator () const
 
SampleTagIterator getSampleTagIterator () const
 
VariableIterator getVariableIterator () const
 
void initSensors ()
 Initialize all sensors for a Project.
 
void initSensors (Site *site)
 Initialize all sensors for a given Site.
 
void initSensors (DSMConfig *dsm)
 Initialize all sensors for a given dsm.
 
const ParametergetParameter (const std::string &name) const
 
void fromDOMElement (const xercesc::DOMElement *)
 
xercesc::DOMElement * toDOMParent (xercesc::DOMElement *parent, bool complete) const
 
xercesc::DOMElement * toDOMElement (xercesc::DOMElement *node, bool complete) const
 
std::string expandString (const std::string &input) const
 Utility function to expand ${TOKEN} or $TOKEN fields in a string with their value from getTokenValue().
 
bool getTokenValue (const std::string &token, std::string &value) const
 Implement a lookup for tokens that I know about, like $PROJECT, and $SYSTEM.
 
const DictionarygetDictionary () const
 
void setDataset (const Dataset &val)
 
const DatasetgetDataset () const
 
void disableAutoconfig (bool disable)
 When true, autoconfig elements in the config document are removed before realizing the Project with fromDOMElement().
 

Static Public Member Functions

static ProjectgetInstance ()
 Project is a singleton.
 
static void destroyInstance ()
 Destory the singleton.
 
static const XMLChgetNamespaceURI ()
 

Protected Member Functions

void addParameter (Parameter *val)
 Add a parameter to this Project.
 

Private Member Functions

void removeAutoConfig (xercesc::DOMNode *node, bool bumpRecursion=false)
 Scan the DOM and pull out any <autoconfig> tags, as well as change the autoconfig classes back to DSMSerialSensor, or isff.PropVane as needed, and remove porttype attributes.
 
 Project (const Project &)
 Copy not supported.
 
Projectoperator= (const Project &)
 Assignment not supported.
 

Private Attributes

std::string _name
 
std::string _sysname
 
std::string _configVersion
 
std::string _configName
 Name of XML file that this project was initialized from.
 
std::string _flightName
 
nidas::core::Project::MyDictionary _dictionary
 
std::list< Site * > _sites
 
SensorCatalog_sensorCatalog
 
DSMCatalog_dsmCatalog
 
ServiceCatalog_serviceCatalog
 
std::list< DSMServer * > _servers
 
nidas::util::Mutex _lookupLock
 
std::map< dsm_sample_id_t, const DSMConfig * > _dsmById
 
nidas::util::Mutex _sensorMapLock
 
std::map< dsm_sample_id_t, DSMSensor * > _sensorById
 
std::map< int, Site * > _siteByStationNumber
 
std::map< std::string, Site * > _siteByName
 
std::set< dsm_sample_id_t_usedIds
 
int _maxSiteNumber
 
int _minSiteNumber
 
std::list< Parameter * > _parameters
 List of pointers to Parameters.
 
Dataset _dataset
 The current dataset.
 
bool _disableAutoconfig
 

Static Private Attributes

static Project_instance = 0
 
static XMLChnamespaceURI = 0
 

Constructor & Destructor Documentation

◆ Project() [1/2]

Project::Project ( )

References _instance.

Referenced by getInstance().

◆ ~Project()

Project::~Project ( )
virtual

◆ Project() [2/2]

nidas::core::Project::Project ( const Project & )
private

Copy not supported.

The main problem with a supporting a copy constructor is that one would need a clone for all the DSMSensors, which would be hard to get and keep correct. Instead of copying/cloning a project, create a new one and initialize it from a DOMElement.

Member Function Documentation

◆ addParameter()

void nidas::core::Project::addParameter ( Parameter * val)
inlineprotected

Add a parameter to this Project.

Project will then own the pointer and will delete it in its destructor.

References _parameters.

Referenced by fromDOMElement().

◆ addServer()

void nidas::core::Project::addServer ( DSMServer * srvr)
inline

A Project has one or more DSMServers.

References _servers.

Referenced by fromDOMElement().

◆ addSite()

void Project::addSite ( Site * val)

◆ destroyInstance()

void Project::destroyInstance ( )
static

Destory the singleton.

References _instance.

Referenced by main(), AutoProject::~AutoProject(), and nidas::core::NidasApp::~NidasApp().

◆ disableAutoconfig()

void nidas::core::Project::disableAutoconfig ( bool disable)
inline

When true, autoconfig elements in the config document are removed before realizing the Project with fromDOMElement().

References _disableAutoconfig, and nidas::core::getSample().

Referenced by nidas::core::DSMEngine::initialize().

◆ expandString()

std::string nidas::core::Project::expandString ( const std::string & input) const
inline

Utility function to expand ${TOKEN} or $TOKEN fields in a string with their value from getTokenValue().

If curly brackets are not used, then the TOKEN should be delimited by a '/', a '.' or the end of string, e.g.: xxx/yyy/$ZZZ.dat

References _dictionary, and nidas::core::Dictionary::expandString().

◆ findDSM() [1/3]

const DSMConfig * Project::findDSM ( const nidas::util::Inet4Address & addr) const

◆ findDSM() [2/3]

const DSMConfig * Project::findDSM ( const std::string & name) const

Find a DSMConfig in any site in this project whose name matches the given hostname.

If the hostname is fully qualified, then the match is attempted against the long name first and then the shortened name, with everything past the first '.' removed.

If there is only one DSM in the project config, then that DSM is always returned.

DSMEngine uses this method to look up it's DSMConfig instance on startup, based on the current hostname setting.

References DLOG, findDSM(), nidas::core::getSample(), getSites(), and WLOG.

◆ findDSM() [3/3]

const DSMConfig * Project::findDSM ( unsigned int id) const

◆ findSampleOutputStreamFileSets() [1/2]

list< nidas::core::FileSet * > Project::findSampleOutputStreamFileSets ( ) const

◆ findSampleOutputStreamFileSets() [2/2]

list< nidas::core::FileSet * > Project::findSampleOutputStreamFileSets ( const std::string & dsmName) const

Find SampleOutputStreamFileSets belonging to the given DSM.

References findDSM(), and nidas::core::getSample().

◆ findSensor() [1/2]

DSMSensor * Project::findSensor ( const SampleTag * tag) const

◆ findSensor() [2/2]

DSMSensor * Project::findSensor ( dsm_sample_id_t id) const

◆ findServer()

DSMServer * Project::findServer ( const nidas::util::Inet4Address & addr) const

◆ findServers()

list< DSMServer * > Project::findServers ( const std::string & hostname) const

Look for a server for this project that either has no name or whose name matches hostname.

Look for a server for this project that whose name matches my hostname.

If none found, remove any domain names and try again. Then search the project Sites.

If none found, remove any domain names and try again. If still none found return any configured servers with no name.

References findServer(), getDSMServerIterator(), nidas::core::DSMServer::getName(), and nidas::core::getSample().

Referenced by findServerSampleOutputStreamFileSets().

◆ findServerSampleOutputStreamFileSets() [1/2]

list< nidas::core::FileSet * > Project::findServerSampleOutputStreamFileSets ( ) const

Call findServerSampleOutputStreamFileSets(name) passing the nodename returned by uname(2).

Exceptions
nidas::util::Exception

References findServerSampleOutputStreamFileSets(), nidas::core::getSample(), and WLOG.

Referenced by findServerSampleOutputStreamFileSets().

◆ findServerSampleOutputStreamFileSets() [2/2]

list< nidas::core::FileSet * > Project::findServerSampleOutputStreamFileSets ( const std::string & name) const

Find SampleOutputStreamFileSets belonging to SampleArchivers of DSMServers whose name matches the argument name.

If no DSMServer names exactly match, then return the filesets corresponding to a DSMServer with an empty name.

References findServers(), nidas::core::SampleOutput::getIOChannel(), nidas::core::SampleIOProcessor::getOutputs(), and nidas::core::getSample().

◆ findSite() [1/2]

Site * Project::findSite ( const std::string & name) const

Find a Site with the given name.

References _lookupLock, _siteByName, and nidas::core::getSample().

◆ findSite() [2/2]

Site * Project::findSite ( int stationNumber) const

Find a Site with the given station number.

References _lookupLock, _siteByStationNumber, and nidas::core::getSample().

◆ fromDOMElement()

void Project::fromDOMElement ( const xercesc::DOMElement * node)
virtual

◆ getConfigName()

const std::string & nidas::core::Project::getConfigName ( ) const
inline

References _configName.

◆ getConfigVersion()

const std::string & nidas::core::Project::getConfigVersion ( ) const
inline

References _configVersion.

◆ getDataset()

const Dataset & nidas::core::Project::getDataset ( ) const
inline

References _dataset.

◆ getDictionary()

const Dictionary & nidas::core::Project::getDictionary ( ) const
inline

References _dictionary.

◆ getDSMCatalog()

DSMCatalog * nidas::core::Project::getDSMCatalog ( ) const
inline

References _dsmCatalog.

◆ getDSMConfigIterator()

DSMConfigIterator Project::getDSMConfigIterator ( ) const

◆ getDSMServerIterator()

DSMServerIterator Project::getDSMServerIterator ( ) const

Referenced by findServer(), and findServers().

◆ getDSMServiceIterator()

DSMServiceIterator Project::getDSMServiceIterator ( ) const

◆ getFlightName()

const string & Project::getFlightName ( ) const

◆ getInstance()

Project * Project::getInstance ( )
static

Project is a singleton.

References _instance, and Project().

Referenced by nidas::dynld::StatisticsProcessor::addRequestedSampleTag(), AutoProject::AutoProject(), nidas::dynld::RawSampleService::connect(), nidas::dynld::raf::SyncRecordSource::connect(), nidas::dynld::XMLConfigService::connected(), nidas::dynld::UDPSampleOutput::connected(), nidas::dynld::raf::CVIProcessor::connectSource(), nidas::dynld::isff::WisardMote::createSampleTag(), nidas::core::NearestResampler::ctorCommon(), nidas::core::SampleTag::fromDOMElement(), nidas::core::Variable::fromDOMElement(), nidas::core::SampleIOProcessor::fromDOMElement(), nidas::core::SampleOutputBase::fromDOMElement(), nidas::core::NidasApp::getProject(), nidas::dynld::UDPSampleOutput::getProjectDOM(), nidas::dynld::isff::WindOrienter::handleParameter(), nidas::dynld::ParoSci_202BG_P::init(), nidas::dynld::ParoSci_202BG_T::init(), nidas::dynld::raf::SyncServer::initProject(), nidas::dynld::raf::SyncServer::initSensors(), main(), nidas::core::NearestResamplerAtRate::NearestResamplerAtRate(), nidas::dynld::isff::Wind3D::parseParameters(), ARLIngest::prepareHeaderIds(), nidas::core::SampleScanner::readBuffer(), DataStats::run(), DmdA2dCk::run(), DataPrep::run(), ExtractFast2D::run(), ExtractDMT::run(), nidas::dynld::XMLConfigService::Worker::run(), nidas::core::SampleAverager::SampleAverager(), nidas::core::SampleAverager::SampleAverager(), nidas::core::SampleAverager::SampleAverager(), nidas::core::HeaderSource::setDefaults(), nidas::core::FileSet::setDir(), nidas::core::FileSet::setFileName(), and nidas::dynld::SampleInputStream::setIOChannel().

◆ getMaxSiteNumber()

int nidas::core::Project::getMaxSiteNumber ( ) const
inline

Convenience function to return the maximum site number.

References _maxSiteNumber.

◆ getMinSiteNumber()

int nidas::core::Project::getMinSiteNumber ( ) const
inline

References _minSiteNumber.

◆ getName()

const std::string & nidas::core::Project::getName ( ) const
inline

◆ getNamespaceURI()

static const XMLCh * nidas::core::DOMable::getNamespaceURI ( )
inlinestaticinherited

◆ getParameter()

const Parameter * Project::getParameter ( const std::string & name) const

◆ getProcessorIterator()

ProcessorIterator Project::getProcessorIterator ( ) const

◆ getSampleTagIterator()

SampleTagIterator Project::getSampleTagIterator ( ) const

Referenced by getUniqueSampleId().

◆ getSensorCatalog()

SensorCatalog * nidas::core::Project::getSensorCatalog ( ) const
inline

References _sensorCatalog.

◆ getSensorIterator()

SensorIterator Project::getSensorIterator ( ) const

◆ getServers()

const std::list< DSMServer * > & nidas::core::Project::getServers ( ) const
inline

References _servers.

◆ getServiceCatalog()

ServiceCatalog * nidas::core::Project::getServiceCatalog ( ) const
inline

References _serviceCatalog.

◆ getSiteIterator()

SiteIterator Project::getSiteIterator ( ) const

Referenced by findDSM(), findSensor(), and toDOMElement().

◆ getSites()

const std::list< Site * > & nidas::core::Project::getSites ( ) const
inline

References _sites.

Referenced by findDSM(), initSensors(), initSensors(), and initSensors().

◆ getSystemName()

const std::string & nidas::core::Project::getSystemName ( ) const
inline

◆ getTokenValue()

bool nidas::core::Project::getTokenValue ( const std::string & token,
std::string & value ) const
inline

Implement a lookup for tokens that I know about, like $PROJECT, and $SYSTEM.

For other tokens, look them up in the process environment.

References _dictionary, and nidas::core::Project::MyDictionary::getTokenValue().

◆ getUniqueSampleId()

dsm_sample_id_t Project::getUniqueSampleId ( unsigned int dsmid)

Get a temporary unique sample id for a given DSM id.

This id can be used for identifying derived samples during processing, when they are passed between SampleSources and SampleClients. The value of these ids is not saved anywhere, and so they are meant to be used for temporary connections, not for archived samples.

References _sensorMapLock, _usedIds, GET_DSM_ID, GET_SPS_ID, nidas::core::SampleTag::getId(), nidas::core::getSample(), getSampleTagIterator(), PLOG, SET_DSM_ID, and SET_SHORT_ID.

◆ getVariableIterator()

VariableIterator Project::getVariableIterator ( ) const

◆ initSensors() [1/3]

void Project::initSensors ( )

Initialize all sensors for a Project.

Exceptions
nidas::util::IOException

References nidas::core::getSample(), and getSites().

Referenced by nidas::core::DSMServer::scheduleServices().

◆ initSensors() [2/3]

void Project::initSensors ( DSMConfig * dsm)

Initialize all sensors for a given dsm.

Exceptions
nidas::util::IOException

References nidas::core::getSample(), and getSites().

◆ initSensors() [3/3]

void Project::initSensors ( Site * site)

Initialize all sensors for a given Site.

Initialize all sensors for a Site.

Exceptions
nidas::util::IOException

References nidas::core::getSample(), and getSites().

◆ operator=()

Project & nidas::core::Project::operator= ( const Project & )
private

Assignment not supported.

See comments about copy constructor.

◆ parseXMLConfigFile()

void Project::parseXMLConfigFile ( const std::string & xmlfilepath)

Convenient method to fill this Project instance from the configuration in the XML file at xmlfilepath, using the nidas::core::parseXMLConfigFile() function.

Exceptions
nidas::core::XMLException

References fromDOMElement(), nidas::core::getSample(), nidas::core::parseXMLConfigFile(), and nidas::core::XMLImplementation::terminate().

◆ removeAutoConfig()

void Project::removeAutoConfig ( xercesc::DOMNode * node,
bool bumpRecursion = false )
private

Scan the DOM and pull out any <autoconfig> tags, as well as change the autoconfig classes back to DSMSerialSensor, or isff.PropVane as needed, and remove porttype attributes.

References nidas::core::getSample(), ILOG, removeAutoConfig(), and VLOG.

Referenced by fromDOMElement(), and removeAutoConfig().

◆ setConfigName()

void nidas::core::Project::setConfigName ( const std::string & val)
inline

◆ setConfigVersion()

void nidas::core::Project::setConfigVersion ( const std::string & val)
inline

References _configVersion, and nidas::core::getSample().

Referenced by fromDOMElement().

◆ setDataset()

void nidas::core::Project::setDataset ( const Dataset & val)
inline

◆ setDSMCatalog()

void nidas::core::Project::setDSMCatalog ( DSMCatalog * val)
inline

References _dsmCatalog, and nidas::core::getSample().

Referenced by fromDOMElement().

◆ setFlightName()

void nidas::core::Project::setFlightName ( const std::string & val)
inline

◆ setName()

void nidas::core::Project::setName ( const std::string & val)
inline

References _name, and nidas::core::getSample().

Referenced by fromDOMElement().

◆ setSensorCatalog()

void nidas::core::Project::setSensorCatalog ( SensorCatalog * val)
inline

References _sensorCatalog, and nidas::core::getSample().

Referenced by fromDOMElement().

◆ setServiceCatalog()

void nidas::core::Project::setServiceCatalog ( ServiceCatalog * val)
inline

◆ setSystemName()

void nidas::core::Project::setSystemName ( const std::string & val)
inline

References _sysname, and nidas::core::getSample().

Referenced by fromDOMElement().

◆ toDOMElement()

xercesc::DOMElement * Project::toDOMElement ( xercesc::DOMElement * node,
bool complete ) const
virtual

◆ toDOMParent()

xercesc::DOMElement * Project::toDOMParent ( xercesc::DOMElement * parent,
bool complete ) const
virtual
Exceptions
xercesc::DOMException

Reimplemented from nidas::core::DOMable.

References nidas::core::DOMable::getNamespaceURI(), and toDOMElement().

Member Data Documentation

◆ _configName

std::string nidas::core::Project::_configName
private

Name of XML file that this project was initialized from.

Referenced by getConfigName(), and setConfigName().

◆ _configVersion

std::string nidas::core::Project::_configVersion
private

◆ _dataset

Dataset nidas::core::Project::_dataset
private

The current dataset.

Referenced by getDataset(), and setDataset().

◆ _dictionary

nidas::core::Project::MyDictionary nidas::core::Project::_dictionary
private

◆ _disableAutoconfig

bool nidas::core::Project::_disableAutoconfig
private

◆ _dsmById

std::map<dsm_sample_id_t,const DSMConfig*> nidas::core::Project::_dsmById
mutableprivate

Referenced by findDSM().

◆ _dsmCatalog

DSMCatalog* nidas::core::Project::_dsmCatalog
private

◆ _flightName

std::string nidas::core::Project::_flightName
mutableprivate

Referenced by getFlightName(), and setFlightName().

◆ _instance

Project * Project::_instance = 0
staticprivate

◆ _lookupLock

nidas::util::Mutex nidas::core::Project::_lookupLock
mutableprivate

◆ _maxSiteNumber

int nidas::core::Project::_maxSiteNumber
private

◆ _minSiteNumber

int nidas::core::Project::_minSiteNumber
private

Referenced by addSite(), and getMinSiteNumber().

◆ _name

std::string nidas::core::Project::_name
private

Referenced by getName(), and setName().

◆ _parameters

std::list<Parameter*> nidas::core::Project::_parameters
private

List of pointers to Parameters.

Referenced by addParameter(), getParameter(), and ~Project().

◆ _sensorById

std::map<dsm_sample_id_t,DSMSensor*> nidas::core::Project::_sensorById
mutableprivate

Referenced by findSensor().

◆ _sensorCatalog

SensorCatalog* nidas::core::Project::_sensorCatalog
private

◆ _sensorMapLock

nidas::util::Mutex nidas::core::Project::_sensorMapLock
mutableprivate

Referenced by findSensor(), and getUniqueSampleId().

◆ _servers

std::list<DSMServer*> nidas::core::Project::_servers
private

Referenced by addServer(), getServers(), and ~Project().

◆ _serviceCatalog

ServiceCatalog* nidas::core::Project::_serviceCatalog
private

◆ _siteByName

std::map<std::string,Site*> nidas::core::Project::_siteByName
private

Referenced by addSite(), and findSite().

◆ _siteByStationNumber

std::map<int,Site*> nidas::core::Project::_siteByStationNumber
private

Referenced by addSite(), and findSite().

◆ _sites

std::list<Site*> nidas::core::Project::_sites
private

Referenced by addSite(), getSites(), and ~Project().

◆ _sysname

std::string nidas::core::Project::_sysname
private

Referenced by getSystemName(), and setSystemName().

◆ _usedIds

std::set<dsm_sample_id_t> nidas::core::Project::_usedIds
private

Referenced by getUniqueSampleId().

◆ namespaceURI

XMLCh * DOMable::namespaceURI = 0
staticprivateinherited

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