nidas  v1.2-1520
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 throw (nidas::core::XMLException)
 Convenient method to fill this Project instance from the configuration in the XML file at xmlfilepath, using the nidas::core::parseXMLConfigFile() function. More...
 
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. More...
 
int getMinSiteNumber () const
 
void addServer (DSMServer *srvr)
 A Project has one or more DSMServers. More...
 
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. More...
 
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. More...
 
const DSMConfigfindDSM (const std::string &name) const
 
DSMConfigfindDSMFromHostname (const std::string &hostname)
 Find a DSMConfig in any site in this project whose name matches the given hostname. More...
 
const DSMConfigfindDSM (unsigned int id) const
 Find a DSM matching id;. More...
 
std::list< nidas::core::FileSet * > findServerSampleOutputStreamFileSets (const std::string &name) const
 Find SampleOutputStreamFileSets belonging to SampleArchivers of DSMServers whose name matches the argument name. More...
 
std::list< nidas::core::FileSet * > findServerSampleOutputStreamFileSets () const throw (nidas::util::Exception)
 Call findServerSampleOutputStreamFileSets(name) passing the nodename returned by uname(2). More...
 
std::list< nidas::core::FileSet * > findSampleOutputStreamFileSets (const std::string &dsmName) const
 Find SampleOutputStreamFileSets belonging to the given DSM. More...
 
std::list< nidas::core::FileSet * > findSampleOutputStreamFileSets () const
 Find SampleOutputStreamFileSets of all DSMs. More...
 
DSMSensorfindSensor (dsm_sample_id_t id) const
 
DSMSensorfindSensor (const SampleTag *tag) const
 
SitefindSite (int stationNumber) const
 Find a Site with the given station number. More...
 
SitefindSite (const std::string &name) const
 Find a Site with the given name. More...
 
dsm_sample_id_t getUniqueSampleId (unsigned int dsmid)
 Get a temporary unique sample id for a given DSM id. More...
 
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 () throw (nidas::util::IOException)
 Initialize all sensors for a Project. More...
 
void initSensors (Site *site) throw (nidas::util::IOException)
 Initialize all sensors for a given Site. More...
 
void initSensors (DSMConfig *dsm) throw (nidas::util::IOException)
 Initialize all sensors for a given dsm. More...
 
const ParametergetParameter (const std::string &name) const
 
void fromDOMElement (const xercesc::DOMElement *) throw (nidas::util::InvalidParameterException)
 Initialize myself from a xercesc::DOMElement. More...
 
xercesc::DOMElement * toDOMParent (xercesc::DOMElement *parent, bool complete) const throw (xercesc::DOMException)
 Create a DOMElement and append it to the parent. More...
 
xercesc::DOMElement * toDOMElement (xercesc::DOMElement *node, bool complete) const throw (xercesc::DOMException)
 Add my content into a DOMElement. More...
 
std::string expandString (const std::string &input) const
 Utility function to expand ${TOKEN} or $TOKEN fields in a string with their value from getTokenValue(). More...
 
bool getTokenValue (const std::string &token, std::string &value) const
 Implement a lookup for tokens that I know about, like $PROJECT, and $SYSTEM. More...
 
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(). More...
 

Static Public Member Functions

static ProjectgetInstance ()
 Project is a singleton. More...
 
static void destroyInstance ()
 Destory the singleton. More...
 
static const XMLCh * getNamespaceURI ()
 

Protected Member Functions

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

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. More...
 
 Project (const Project &)
 Copy not supported. More...
 
Projectoperator= (const Project &)
 Assignment not supported. More...
 

Private Attributes

std::string _name
 
std::string _sysname
 
std::string _configVersion
 
std::string _configName
 Name of XML file that this project was initialized from. More...
 
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. More...
 
Dataset _dataset
 The current dataset. More...
 
bool _disableAutoconfig
 

Static Private Attributes

static Project_instance = 0
 

Constructor & Destructor Documentation

Project::Project ( )

References _instance.

Project::~Project ( )
virtual
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

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.

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

A Project has one or more DSMServers.

References _servers.

void Project::addSite ( Site val)
void Project::destroyInstance ( )
static

Destory the singleton.

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

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.

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().

Referenced by nidas::core::XMLConfigWriterFilter::acceptDSMNode(), nidas::dynld::StatisticsProcessor::addRequestedSampleTag(), nidas::dynld::isff::WisardMote::createSampleTag(), nidas::core::DSMConfig::fromDOMElement(), nidas::core::SampleTag::fromDOMElement(), nidas::core::Variable::fromDOMElement(), and nidas::dynld::isff::WindOrienter::handleParameter().

const DSMConfig * Project::findDSM ( const nidas::util::Inet4Address addr) const
const DSMConfig * Project::findDSM ( const std::string &  name) const
const DSMConfig * Project::findDSM ( unsigned int  id) const
DSMConfig * Project::findDSMFromHostname ( const std::string &  hostname)

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 entire 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 nidas::core::Site::getDSMConfigs(), nidas::util::Logger::getInstance(), nidas::core::DSMConfig::getName(), getSites(), nidas::util::Logger::log(), and LOG_INFO.

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

Find SampleOutputStreamFileSets belonging to the given DSM.

References findDSM(), and nidas::core::DSMConfig::findSampleOutputStreamFileSets().

Referenced by StatsProcess::run(), and DataPrep::run().

list< nidas::core::FileSet * > Project::findSampleOutputStreamFileSets ( ) const
DSMSensor * Project::findSensor ( dsm_sample_id_t  id) const
DSMSensor * Project::findSensor ( const SampleTag tag) const
DSMServer * Project::findServer ( const nidas::util::Inet4Address addr) const
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(), nidas::util::Inet4Address::getAllByName(), getDSMServerIterator(), nidas::core::DSMServer::getName(), nidas::core::DSMServerIterator::hasNext(), and nidas::core::DSMServerIterator::next().

Referenced by findServerSampleOutputStreamFileSets(), StatsProcess::getStatisticsProcessor(), and nidas::core::DSMServerApp::run().

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::DSMServer::getName(), nidas::core::SampleIOProcessor::getOutputs(), nidas::core::DSMServer::getProcessorIterator(), nidas::core::ProcessorIterator::hasNext(), and nidas::core::ProcessorIterator::next().

Referenced by nidas::core::GetAdsFileName::execute(), StatsProcess::run(), and DataPrep::run().

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

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

References WLOG.

Site * Project::findSite ( int  stationNumber) const

Find a Site with the given station number.

References _lookupLock, and _siteByStationNumber.

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

Find a Site with the given name.

References _lookupLock, and _siteByName.

void Project::fromDOMElement ( const xercesc::DOMElement *  )
throw (nidas::util::InvalidParameterException
)
virtual
const std::string& nidas::core::Project::getConfigName ( ) const
inline

References _configName.

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

References _configVersion.

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

References _dataset.

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

References _dictionary.

DSMCatalog* nidas::core::Project::getDSMCatalog ( ) const
inline
DSMConfigIterator Project::getDSMConfigIterator ( ) const
DSMServerIterator Project::getDSMServerIterator ( ) const

Referenced by findServer(), and findServers().

DSMServiceIterator Project::getDSMServiceIterator ( ) const
const string & Project::getFlightName ( ) const

References _flightName, and _lookupLock.

Project * Project::getInstance ( )
static

Project is a singleton.

Referenced by nidas::dynld::StatisticsProcessor::addRequestedSampleTag(), nidas::dynld::isff::GOESOutput::addSourceSampleTag(), AutoProject::AutoProject(), nidas::dynld::RawSampleService::connect(), nidas::dynld::psql::PSQLProcessor::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::NearestResamplerAtRate::ctorCommon(), nidas::core::SampleIOProcessor::fromDOMElement(), nidas::core::SampleOutputBase::fromDOMElement(), nidas::core::SampleTag::fromDOMElement(), nidas::core::Variable::fromDOMElement(), nidas::dynld::isff::PacketInputStream::getGOESProject(), 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::psql::PSQLSampleOutput::initializeGlobalAttributes(), nidas::dynld::raf::SyncServer::initProject(), nidas::dynld::raf::SyncServer::initSensors(), main(), nidas::dynld::isff::Wind3D::parseParameters(), ARLIngest::prepareHeaderIds(), nidas::core::SampleScanner::readBuffer(), nidas::dynld::XMLConfigService::Worker::run(), ExtractDMT::run(), ExtractFast2D::run(), nidas::core::SampleAverager::SampleAverager(), nidas::core::HeaderSource::setDefaults(), nidas::core::FileSet::setDir(), nidas::core::FileSet::setFileName(), and nidas::dynld::SampleInputStream::setIOChannel().

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

Convenience function to return the maximum site number.

References _maxSiteNumber.

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

References _minSiteNumber.

const std::string& nidas::core::Project::getName ( ) const
inline
static const XMLCh* nidas::core::DOMable::getNamespaceURI ( )
inlinestaticinherited
const Parameter * Project::getParameter ( const std::string &  name) const
ProcessorIterator Project::getProcessorIterator ( ) const
SampleTagIterator Project::getSampleTagIterator ( ) const

Referenced by getUniqueSampleId().

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

References _servers.

ServiceCatalog* nidas::core::Project::getServiceCatalog ( ) const
inline
SiteIterator Project::getSiteIterator ( ) const
const std::list<Site*>& nidas::core::Project::getSites ( ) const
inline
const std::string& nidas::core::Project::getSystemName ( ) const
inline
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().

Referenced by nidas::core::Site::MyDictionary::getTokenValue().

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::util::Logger::getInstance(), getSampleTagIterator(), nidas::core::SampleTagIterator::hasNext(), nidas::util::Logger::log(), LOG_ERR, nidas::core::SampleTagIterator::next(), SET_DSM_ID, and SET_SHORT_ID.

Referenced by nidas::core::NearestResampler::ctorCommon(), and nidas::core::NearestResamplerAtRate::ctorCommon().

VariableIterator Project::getVariableIterator ( ) const
void Project::initSensors ( )
throw (nidas::util::IOException
)

Initialize all sensors for a Project.

References getSites(), and nidas::core::Site::initSensors().

void Project::initSensors ( Site site)
throw (nidas::util::IOException
)

Initialize all sensors for a given Site.

Initialize all sensors for a Site.

References nidas::core::Site::initSensors().

void Project::initSensors ( DSMConfig dsm)
throw (nidas::util::IOException
)

Initialize all sensors for a given dsm.

References nidas::core::Site::initSensors().

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

Assignment not supported.

See comments about copy constructor.

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::XDOMElement::getAttributeValue(), nidas::core::XDOMElement::getElement(), nidas::core::XDOMElement::getNodeName(), ILOG, nidas::core::XDOMElement::setAttributeValue(), and VLOG.

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

References _configVersion.

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

References _dsmCatalog.

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

References _flightName.

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

References _name.

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

References _sensorCatalog.

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

References _serviceCatalog.

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

References _sysname.

void Project::throw ( nidas::core::XMLException  )

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

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

xercesc::DOMElement * Project::toDOMElement ( xercesc::DOMElement *  node,
bool  complete 
) const
throw (xercesc::DOMException
)
virtual
xercesc::DOMElement * Project::toDOMParent ( xercesc::DOMElement *  parent,
bool  complete 
) const
throw (xercesc::DOMException
)
virtual

Create a DOMElement and append it to the parent.

Reimplemented from nidas::core::DOMable.

References nidas::core::DOMable::getNamespaceURI().

Member Data Documentation

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

Name of XML file that this project was initialized from.

Referenced by getConfigName(), and setConfigName().

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

The current dataset.

Referenced by getDataset(), and setDataset().

nidas::core::Project::MyDictionary nidas::core::Project::_dictionary
private
bool nidas::core::Project::_disableAutoconfig
private

Referenced by disableAutoconfig().

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

Referenced by findDSM().

DSMCatalog* nidas::core::Project::_dsmCatalog
private
std::string nidas::core::Project::_flightName
mutableprivate

Referenced by getFlightName(), and setFlightName().

Project * Project::_instance = 0
staticprivate

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

nidas::util::Mutex nidas::core::Project::_lookupLock
mutableprivate
int nidas::core::Project::_maxSiteNumber
private

Referenced by addSite(), and getMaxSiteNumber().

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

Referenced by addSite(), and getMinSiteNumber().

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

Referenced by getName(), and setName().

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

List of pointers to Parameters.

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

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

Referenced by findSensor().

SensorCatalog* nidas::core::Project::_sensorCatalog
private
nidas::util::Mutex nidas::core::Project::_sensorMapLock
mutableprivate

Referenced by findSensor(), and getUniqueSampleId().

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

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

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

Referenced by addSite(), and findSite().

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

Referenced by addSite(), and findSite().

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

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

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

Referenced by getSystemName(), and setSystemName().

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

Referenced by getUniqueSampleId().


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