AISResources Class Reference

Manage AIS resources. More...

#include <AISResources.h>

Collaboration diagram for AISResources:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 AISResources (const string &database) throw (AISDatabaseReadFailed)
 AISResources ()
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)
virtual ~AISResources ()
Methods used by the AISDatabaseParser class
virtual void add_regexp_resource (const string &regexp, const ResourceVector &rv)
virtual void add_regexp_resource (const string &regexp, const Resource &ancillary)
virtual void add_url_resource (const string &url, const ResourceVector &rv)
virtual void add_url_resource (const string &url, const Resource &ancillary)

Friends

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

Classes

struct  FindRegexp
struct  MatchRegexp

Detailed Description

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 67 of file AISResources.h.


Constructor & Destructor Documentation

AISResources::AISResources (  )  [inline]

Build an empty instance.

Definition at line 118 of file AISResources.h.

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

Use an existing AIS database to build an instance.

Parameters:
database Pathname of the database/document.

Definition at line 101 of file AISResources.cc.

virtual AISResources::~AISResources (  )  [inline, virtual]

Definition at line 122 of file AISResources.h.


Member Function Documentation

void 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 154 of file AISResources.cc.

void 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 142 of file AISResources.cc.

void 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 124 of file AISResources.cc.

void 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 113 of file AISResources.cc.

ResourceVector 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:
NoSuchPrimaryResource thrown if primary is not present in the current mapping.

Definition at line 209 of file AISResources.cc.

Referenced by AISMerge::merge().

bool 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 177 of file AISResources.cc.

Referenced by AISMerge::merge().

void 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:
AISDatabaseReadFailed thrown if the database could not be read.

Definition at line 238 of file AISResources.cc.

References AISDatabaseParser::intern().

Here is the call graph for this function:

void 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:
AISDatabaseWriteFailed thrown if the database could not be written.

Definition at line 254 of file AISResources.cc.


Friends And Related Function Documentation

friend class AISResourcesTest [friend]

Definition at line 113 of file AISResources.h.

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 58 of file AISResources.cc.


The documentation for this class was generated from the following files:
Generated on Wed Jun 27 12:57:21 2007 for libdap++ by  doxygen 1.4.7