libdap  Updated for version 3.20.6
libdap4 is an implementation of OPeNDAP's DAP protocol.
libdap::AISResources Class Reference

Manage AIS resources. More...

#include <AISResources.h>

Public Member Functions

 AISResources ()
 
 AISResources (const string &database) throw (AISDatabaseReadFailed)
 
virtual ResourceVector get_resource (const string &primary)
 
virtual bool has_resource (const string &primary) const
 
virtual void read_database (const string &database)
 
virtual void write_database (const string &filename)
 
Methods used by the AISDatabaseParser class
virtual void add_url_resource (const string &url, const Resource &ancillary)
 
virtual void add_url_resource (const string &url, const ResourceVector &rv)
 
virtual void add_regexp_resource (const string &regexp, const Resource &ancillary)
 
virtual void add_regexp_resource (const string &regexp, const ResourceVector &rv)
 

Friends

class AISResourcesTest
 
ostream & operator<< (ostream &os, const AISResources &ais_res)
 

Detailed Description

Manage AIS resources.

Maintain a database of AIS resources. Groups of AIS resources are accessed using a primary resource. The AISResources object is the in-memory database of mappings between 'primary' and 'ancillary' resources.

Note that read_database() takes filenames because the underlying XML parser library uses filenames. The write_database() method takes a filename to be symmetrical.

Note
The word 'primary,' as in 'primary resource,' means a Data Source URL. This is a URL to a DAP-compliant server that will return DAS, DDS, et c., responses using the DAP. The word 'Ancillary' or 'AIS,' as in 'Ancillary/AIS Resources,' means DAS, DDS, or Data information in a file that the software can access. In practice, these might come from servers, too, but the terms are used to try to keep things sane. A 'primary resource' is the data set and the 'ancillary resource' is the stuff you're trying to jam into it.

Definition at line 70 of file AISResources.h.

Constructor & Destructor Documentation

◆ AISResources() [1/2]

libdap::AISResources::AISResources ( )
inline

Build an empty instance.

Definition at line 121 of file AISResources.h.

◆ AISResources() [2/2]

libdap::AISResources::AISResources ( const string &  database)
throw (AISDatabaseReadFailed
)

Use an existing AIS database to build an instance.

Parameters
databasePathname of the database/document.

Definition at line 105 of file AISResources.cc.

Member Function Documentation

◆ add_regexp_resource() [1/2]

void libdap::AISResources::add_regexp_resource ( const string &  re,
const Resource ancillary 
)
virtual

Add the given ancillary resource to the in-memory collection of mappings between regular expressions and ancillary data sources.

Parameters
reThe target of the new mapping. This is a regular expression.
ancillaryMatch this ancillary resource to the target (primary).

Definition at line 146 of file AISResources.cc.

◆ add_regexp_resource() [2/2]

void libdap::AISResources::add_regexp_resource ( const string &  re,
const ResourceVector &  rv 
)
virtual

Add a vector of AIS resources for the given primary data source regular expression. If there is already an entry for the primary, append the new ancillary resources to those.

Parameters
reThe target of the new mapping.
rvAncillary resources matched to this primary resource.

Definition at line 158 of file AISResources.cc.

◆ add_url_resource() [1/2]

void libdap::AISResources::add_url_resource ( const string &  url,
const Resource ancillary 
)
virtual

Add the given ancillary resource to the in-memory collection of mappings between primary and ancillary data sources.

Parameters
urlThe target of the new mapping.
ancillaryMatch this ancillary resource to the target (primary).

Definition at line 117 of file AISResources.cc.

◆ add_url_resource() [2/2]

void libdap::AISResources::add_url_resource ( const string &  url,
const ResourceVector &  rv 
)
virtual

Add a vector of AIS resources for the given primary data source URL. If there is already an entry for the primary, append the new ancillary resources to those.

Parameters
urlThe target of the new mapping.
rvAncillary resources matched to this primary resource.

Definition at line 128 of file AISResources.cc.

◆ get_resource()

ResourceVector libdap::AISResources::get_resource ( const string &  primary)
virtual

Return a vector of AIS Resource objects which are bound to the given primary resource. If a given primary resource has both an explicit entry for itself and matches a regular expression, the AIS resources for both will be combined in one ResourceVector and returned.

Aside from reading the database, this is the main workhorse for this class. Once a database has been read, a client uses has_resource() to see if a Data URL has anything in the database and then calls this method to get a vector of those things.

Todo:
Make this return an empty ResourceVector is no matching resources are found. Clients would not need to call has_resource() which would save some time.
Parameters
primaryThe URL of the primary resource
Returns
a vector of Resource objects.
Exceptions
NoSuchPrimaryResourcethrown if primary is not present in the current mapping.

Definition at line 213 of file AISResources.cc.

◆ has_resource()

bool libdap::AISResources::has_resource ( const string &  primary) const
virtual

Return True if the given primary resource is listed in the current set of AIS resource mappings. That is, return true if there are some AIS resources registered for the given primary resource.

Parameters
primaryThe URL of the primary resource. That is, a Data Source URL.
Returns
True if there are AIS resources for primary.

Definition at line 181 of file AISResources.cc.

◆ read_database()

void libdap::AISResources::read_database ( const string &  database)
virtual

Read the AIS database (an XML file) and internalize it. This method is almost always used to build an in-memory database that has_resource() and get_resource() use.

Parameters
databaseA file/pathname to the AIS database.
Exceptions
AISDatabaseReadFailedthrown if the database could not be read.

Definition at line 242 of file AISResources.cc.

◆ write_database()

void libdap::AISResources::write_database ( const string &  filename)
virtual

Write the current in-memory mapping of primary and ancillary resources to the named file so that the read_database() method can read them and recreate the in-memory mapping.

Parameters
filenameA local file; write the database to this file. Create if necessary.
Exceptions
AISDatabaseWriteFailedthrown if the database could not be written.

Definition at line 258 of file AISResources.cc.

Friends And Related Function Documentation

◆ operator<<

ostream& operator<< ( ostream &  os,
const AISResources ais_res 
)
friend

Output the XML for a collection of AIS resources. This function is a friend of the AISResource class.

See also
AISResources

Definition at line 62 of file AISResources.cc.


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