BESKeys Class Reference

mapping of key/value pairs defining different behaviors of an application. More...

#include <BESKeys.h>

Inheritance diagram for BESKeys:

Inheritance graph
[legend]
Collaboration diagram for BESKeys:

Collaboration graph
[legend]
List of all members.

Public Types

typedef map< string, string
>::const_iterator 
Keys_citer

Public Member Functions

 ~BESKeys ()
 cleans up the key/value pair mapping
string keys_file_name ()
string set_key (const string &key, const string &val)
 allows the user to set key/value pairs from within the application.
string set_key (const string &pair)
 allows the user to set key/value pairs from within the application.
string get_key (const string &s, bool &found)
 Retrieve the value of a given key, if set.
void show_keys ()
 displays all key/value pairs defined to standard output.
Keys_citer keys_begin ()
Keys_citer keys_end ()
virtual void dump (ostream &strm) const
 dumps information about this object

Protected Member Functions

 BESKeys (const string &keys_file_name)
 default constructor that reads loads key/value pairs from the specified file.

Detailed Description

mapping of key/value pairs defining different behaviors of an application.

BESKeys provides a mechanism to define the behavior of an application given key/value paris. For example, how authentication will work, database access information, level of debugging and where log files are to be located.

Key/value pairs can be loaded from an external initialization file or set within the application itself, for example from the command line.

If from a file the key/value pair is set one per line and cannot span multiple lines. Comments are allowed using the pound (#) character. For example:

 #
 # Who is responsable for this server
 #
 BES.ServerAdministrator=dods-tech.ucar.edu

 #
 # Default server port and unix socket information and whether the server
 is secure or not.
 #
 BES.ServerPort=10002
 BES.ServerUnixSocket=/tmp/bes.socket
 BES.ServerSecure=no
 

Key/value pairs can also be set by passing in a key=value string, or by passing in a key and value string to the object.

BES provides a single object for access to a single BESKeys object, TheBESKeys.

Definition at line 82 of file BESKeys.h.


Member Typedef Documentation

typedef map< string, string >::const_iterator BESKeys::Keys_citer

Definition at line 109 of file BESKeys.h.


Constructor & Destructor Documentation

BESKeys::BESKeys ( const string &  keys_file_name  )  [protected]

default constructor that reads loads key/value pairs from the specified file.

This constructor uses the specified file to load key/value pairs. This file holds different key/value pairs for the application, one key/value pair per line separated by an equal (=) sign.

key=value

Comments are allowed in the file and must begin with a pound (#) sign at the beginning of the line. No comments are allowed at the end of lines.

Exceptions:
BESKeysException thrown if there is an error reading the initialization file or a syntax error in the file, i.e. a malformed key/value pair.

Definition at line 66 of file BESKeys.cc.

BESKeys::~BESKeys (  ) 

cleans up the key/value pair mapping

Definition at line 103 of file BESKeys.cc.


Member Function Documentation

string BESKeys::keys_file_name (  )  [inline]

Definition at line 102 of file BESKeys.h.

string BESKeys::set_key ( const string &  key,
const string &  val 
)

allows the user to set key/value pairs from within the application.

This method allows users of BESKeys to set key/value pairs from within the application, such as for testing purposes, key/value pairs from the command line, etc...

If the key is already set then this value replaces the value currently held in the keys map.

Parameters:
key variable name that can be accessed using the get_key method
val value of the variable returned when get_key is called for this key
Returns:
returns the value of the key, empty string if unsuccessful

Definition at line 254 of file BESKeys.cc.

Referenced by plistT::run(), pfileT::run(), keysT::run(), infoT::run(), containerT::run(), cacheT::run(), and set_key().

string BESKeys::set_key ( const string &  pair  ) 

allows the user to set key/value pairs from within the application.

This method allows users of BESKeys to set key/value pairs from within the application, such as for testing purposes, key/value pairs from the command line, etc...

If the key is already set then this value replaces the value currently held in the keys map.

Parameters:
pair the key/value pair passed as key=value
Returns:
returns the value for the key, empty string if unsuccessful

Definition at line 284 of file BESKeys.cc.

References set_key().

Here is the call graph for this function:

string BESKeys::get_key ( const string &  s,
bool &  found 
)

Retrieve the value of a given key, if set.

This method allows the user of BESKeys to retrieve the value of the specified key.

Parameters:
s The key the user is looking for
found Set to true of the key is set or false if the key is not set. The value of a key can be set to the empty string, which is why this boolean is provided.
Returns:
Returns the value of the key, empty string if the key is not set.

Definition at line 304 of file BESKeys.cc.

Referenced by BESInfo::add_data_from_file(), BESCache::BESCache(), BESCatalogUtils::BESCatalogUtils(), BESContainerStorageFile::BESContainerStorageFile(), BESContainerStorageVolatile::BESContainerStorageVolatile(), BESInfo::BESInfo(), BESLog::BESLog(), BESMemoryGlobalArea::BESMemoryGlobalArea(), BESServerHandler::BESServerHandler(), BESUncompressManager::BESUncompressManager(), BESInfoList::build_info(), BESExceptionManager::handle_exception(), ServerApp::initialize(), and keysT::run().

void BESKeys::show_keys (  ) 

displays all key/value pairs defined to standard output.

This method allows the user to see all of the key/value pairs that are currently defined. The output looks like:

 key: "key", value: "value"
 

Definition at line 330 of file BESKeys.cc.

Referenced by keysT::run().

Keys_citer BESKeys::keys_begin (  )  [inline]

Definition at line 110 of file BESKeys.h.

Referenced by BESKeysResponseHandler::execute().

Keys_citer BESKeys::keys_end (  )  [inline]

Definition at line 111 of file BESKeys.h.

Referenced by BESKeysResponseHandler::execute().

void BESKeys::dump ( ostream &  strm  )  const [virtual]

dumps information about this object

Displays the pointer value of this instance along with all of the keys.

Parameters:
strm C++ i/o stream to dump the information to

Implements BESObj.

Definition at line 348 of file BESKeys.cc.

References BESIndent::Indent(), BESIndent::LMarg(), and BESIndent::UnIndent().

Here is the call graph for this function:


The documentation for this class was generated from the following files:
Generated on Wed Aug 29 03:29:13 2007 for OPeNDAP Back End Server (BES) by  doxygen 1.5.2