Manage AIS resources.
More...
#include <AISResources.h>
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.
◆ AISResources() [1/2]
libdap::AISResources::AISResources |
( |
| ) |
|
|
inline |
◆ AISResources() [2/2]
Use an existing AIS database to build an instance.
- Parameters
-
database | Pathname of the database/document. |
Definition at line 105 of file AISResources.cc.
◆ 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
-
re | The target of the new mapping. This is a regular expression. |
ancillary | Match 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
-
re | The target of the new mapping. |
rv | Ancillary 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
-
url | The target of the new mapping. |
ancillary | Match 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
-
url | The target of the new mapping. |
rv | Ancillary 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
-
primary | The URL of the primary resource |
- Returns
- a vector of Resource objects.
- Exceptions
-
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
-
primary | The 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
-
database | A file/pathname to the AIS database. |
- Exceptions
-
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
-
filename | A local file; write the database to this file. Create if necessary. |
- Exceptions
-
Definition at line 258 of file AISResources.cc.
◆ 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: