SST::Params Class Reference

Parameter store. More...

#include <params.h>

Data Structures

struct  KeyCompare

Public Types

typedef std::map< std::string,
std::string >::key_type 
key_type
typedef std::map< uint32_t,
std::string >::mapped_type 
mapped_type
typedef std::map< std::string,
std::string >::value_type 
value_type
typedef std::map< uint32_t,
std::string >::key_compare 
key_compare
typedef std::map< uint32_t,
std::string >::value_compare 
value_compare
typedef std::map< uint32_t,
std::string >::pointer 
pointer
typedef std::map< uint32_t,
std::string >::reference 
reference
typedef std::map< uint32_t,
std::string >::const_reference 
const_reference
typedef std::map< uint32_t,
std::string >::size_type 
size_type
typedef std::map< uint32_t,
std::string >::difference_type 
difference_type
typedef std::map< uint32_t,
std::string >::iterator 
iterator
typedef std::map< uint32_t,
std::string >::const_iterator 
const_iterator
typedef std::map< uint32_t,
std::string >
::reverse_iterator 
reverse_iterator
typedef std::map< uint32_t,
std::string >
::const_reverse_iterator 
const_reverse_iterator
typedef std::set< key_type,
KeyCompare > 
KeySet_t

Public Member Functions

bool enableVerify (bool enable)
 Enable or disable parameter verification on an instance of Params.
iterator begin ()
 Returns a read/write iterator that points to the first pair in the Params.
iterator end ()
 Returns a read/write iterator that points one past the last pair in the Params.
const_iterator begin () const
 Returns a read-only (constant) iterator that points to the first pair in the Params.
const_iterator end () const
 Returns a read-only (constant) iterator that points one past the last pair in the Params.
reverse_iterator rbegin ()
 Returns a read/write reverse iterator that points to the last pair in the Params.
reverse_iterator rend ()
 Returns a read/write reverse iterator that points to one before the first pair in the Params.
const_reverse_iterator rbegin () const
 Returns a read-only (constant) reverse iterator that points to the last pair in the Params.
const_reverse_iterator rend () const
 Returns a read-only (constant) reverse iterator that points to one before the first pair in the Params.
size_type size () const
 Returns the size of the Params.
size_type max_size () const
 Returns the maximum size of the Params.
bool empty () const
 Returns true if the Params is empty.
 Params ()
 Create a new, empty Params.
 Params (const key_compare &comp)
 Create a new, empty Params with specified key comparison functor.
 Params (const Params &old)
 Create a copy of a Params object.
Paramsoperator= (const Params &old)
 Map assignment operator.
std::pair< iterator, bool > insert (const value_type &x)
 Attempts to insert a std::pair into the map.
iterator insert (iterator pos, const value_type &x)
 Attempts to insert a std::pair into the map.
template<class InputIterator >
void insert (InputIterator f, InputIterator l)
 Template function that attemps to insert a range of elements.
void erase (iterator pos)
 Erases an element from a map.
size_type erase (const key_type &k)
 Erases elements according to the provided key.
void clear ()
 Erases all elements in a map.
iterator find (const key_type &k)
 Tries to locate an element in a map.
const_iterator find (const key_type &k) const
 Tries to locate an element in a map.
size_type count (const key_type &k)
 Finds the number of elements with given key.
mapped_typeoperator[] (const key_type &k)
 Subscript ( [] ) access to map data.
int64_t find_integer (const key_type &k, long default_value, bool &found) const
 Find a Parameter value in the set, and return its value as an integer.
int64_t find_integer (const key_type &k, long default_value=-1) const
 Find a Parameter value in the set, and return its value as an integer.
double find_floating (const key_type &k, double default_value, bool &found) const
 Find a Parameter value in the set, and return its value as a double.
double find_floating (const key_type &k, double default_value=-1.0) const
 Find a Parameter value in the set, and return its value as a double.
std::string find_string (const key_type &k, std::string default_value, bool &found) const
 Find a Parameter value in the set, and return its value.
std::string find_string (const key_type &k, std::string default_value="") const
 Find a Parameter value in the set, and return its value.
void print_all_params (std::ostream &os, std::string prefix="") const
 Print all key/value parameter pairs to specified ostream.
Params find_prefix_params (std::string prefix) const
 Returns a new parameter object with parameters that match the specified prefix.
bool contains (const key_type &k)
void pushAllowedKeys (const KeySet_t &keys)
void popAllowedKeys ()
 Removes the most recent set of keys considered allowed.
void verifyParam (const key_type &k) const

Static Public Member Functions

static void enableVerify ()
 Enable, on a global scale, parameter verification.
static const std::string & getParamName (uint32_t id)
 Given a Parameter Key ID, return the Name of the matching parameter.

Static Public Attributes

static std::map< std::string,
uint32_t > 
keyMap
 NOT FOR PUBLIC USE.
static std::vector< std::string > keyMapReverse
 NOT FOR PUBLIC USE.
static uint32_t nextKeyID
 NOT FOR PUBLIC USE.

Friends

class boost::serialization::access

Detailed Description

Parameter store.

Meets the requirements of a container, a reversible container, and an associative container (using unique keys). For a map<Key,T> the key_type is Key, the mapped_type is T, and the value_type is std::pair<const Key,T>.


Member Typedef Documentation

typedef std::map<uint32_t, std::string>::const_iterator SST::Params::const_iterator

Const Iterator type

typedef std::map<uint32_t, std::string>::const_reference SST::Params::const_reference

Const Reference type

typedef std::map<uint32_t, std::string>::const_reverse_iterator SST::Params::const_reverse_iterator

Const Reverse Iterator type

typedef std::map<uint32_t, std::string>::difference_type SST::Params::difference_type

Difference type

typedef std::map<uint32_t, std::string>::iterator SST::Params::iterator

Iterator type

typedef std::map<uint32_t, std::string>::key_compare SST::Params::key_compare

Key comparator type

typedef std::map<std::string, std::string>::key_type SST::Params::key_type

Type of key (string)

typedef std::set<key_type, KeyCompare> SST::Params::KeySet_t

Type of a set of keys

typedef std::map<uint32_t, std::string>::mapped_type SST::Params::mapped_type

Type of value (string)

typedef std::map<uint32_t, std::string>::pointer SST::Params::pointer

Pointer type

typedef std::map<uint32_t, std::string>::reference SST::Params::reference

Reference type

typedef std::map<uint32_t, std::string>::reverse_iterator SST::Params::reverse_iterator

Reverse Iterator type

typedef std::map<uint32_t, std::string>::size_type SST::Params::size_type

Size type

typedef std::map<uint32_t, std::string>::value_compare SST::Params::value_compare

Value comparator type

typedef std::map<std::string, std::string>::value_type SST::Params::value_type

Pair of strings


Member Function Documentation

const_iterator SST::Params::begin (  )  const [inline]

Returns a read-only (constant) iterator that points to the first pair in the Params.

Iteration is done in ascending order according to the keys.

iterator SST::Params::begin (  )  [inline]

Returns a read/write iterator that points to the first pair in the Params.

Iteration is done in ascending order according to the keys.

Referenced by SST::ConfigGraph::addParams(), and SST::Simulation::performWireUp().

void SST::Params::clear (  )  [inline]

Erases all elements in a map.

Note that this function only erases the elements, and that if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibilty.

bool SST::Params::contains ( const key_type k  )  [inline]
Parameters:
k Key to search for
Returns:
True if the params contains the key, false otherwise
size_type SST::Params::count ( const key_type k  )  [inline]

Finds the number of elements with given key.

Parameters:
k Key of (key, value) pairs to be located.
Returns:
Number of elements with specified key.

This function only makes sense for multimaps; for map the result will either be 0 (not present) or 1 (present).

bool SST::Params::empty (  )  const [inline]

Returns true if the Params is empty.

(Thus begin() would equal end().)

static void SST::Params::enableVerify (  )  [inline, static]

Enable, on a global scale, parameter verification.

Used after construction of the config graph so that warnings are not generated during construction.

Referenced by SST::Simulation::performWireUp().

bool SST::Params::enableVerify ( bool  enable  )  [inline]

Enable or disable parameter verification on an instance of Params.

Useful when generating a new set of Params to pass off to a module.

Referenced by find_prefix_params().

const_iterator SST::Params::end (  )  const [inline]

Returns a read-only (constant) iterator that points one past the last pair in the Params.

Iteration is done in ascending order according to the keys.

iterator SST::Params::end (  )  [inline]

Returns a read/write iterator that points one past the last pair in the Params.

Iteration is done in ascending order according to the keys.

Referenced by SST::ConfigGraph::addParams(), and SST::Simulation::performWireUp().

size_type SST::Params::erase ( const key_type k  )  [inline]

Erases elements according to the provided key.

Parameters:
k Key of element to be erased.
Returns:
The number of elements erased.

This function erases all the elements located by the given key from a map. Note that this function only erases the element, and that if the element is itself a pointer, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibilty.

void SST::Params::erase ( iterator  pos  )  [inline]

Erases an element from a map.

Parameters:
pos An iterator pointing to the element to be erased.

This function erases an element, pointed to by the given iterator, from a map. Note that this function only erases the element, and that if the element is itself a pointer, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibilty.

const_iterator SST::Params::find ( const key_type k  )  const [inline]

Tries to locate an element in a map.

Parameters:
k Key of (key, value) pair to be located.
Returns:
Read-only (constant) iterator pointing to sought-after element, or end() if not found.

This function takes a key and tries to locate the element with which the key matches. If successful the function returns a constant iterator pointing to the sought after pair. If unsuccessful it returns the past-the-end ( end() ) iterator.

References verifyParam().

iterator SST::Params::find ( const key_type k  )  [inline]

Tries to locate an element in a map.

Parameters:
k Key of (key, value) pair to be located.
Returns:
Iterator pointing to sought-after element, or end() if not found.

This function takes a key and tries to locate the element with which the key matches. If successful the function returns an iterator pointing to the sought after pair. If unsuccessful it returns the past-the-end ( end() ) iterator.

References verifyParam().

double SST::Params::find_floating ( const key_type k,
double  default_value = -1.0 
) const [inline]

Find a Parameter value in the set, and return its value as a double.

Parameters:
k - Parameter name
default_value - Default value to return if parameter isn't found

References find_floating().

double SST::Params::find_floating ( const key_type k,
double  default_value,
bool &  found 
) const [inline]

Find a Parameter value in the set, and return its value as a double.

Parameters:
k - Parameter name
default_value - Default value to return if parameter isn't found
found - set to true if the the parameter was found

References verifyParam().

Referenced by find_floating().

int64_t SST::Params::find_integer ( const key_type k,
long  default_value = -1 
) const [inline]

Find a Parameter value in the set, and return its value as an integer.

Parameters:
k - Parameter name
default_value - Default value to return if parameter isn't found

References find_integer().

int64_t SST::Params::find_integer ( const key_type k,
long  default_value,
bool &  found 
) const [inline]

Find a Parameter value in the set, and return its value as an integer.

Parameters:
k - Parameter name
default_value - Default value to return if parameter isn't found
found - set to true if the the parameter was found

References verifyParam().

Referenced by find_integer().

std::string SST::Params::find_string ( const key_type k,
std::string  default_value = "" 
) const [inline]

Find a Parameter value in the set, and return its value.

Parameters:
k - Parameter name
default_value - Default value to return if parameter isn't found

References find_string().

std::string SST::Params::find_string ( const key_type k,
std::string  default_value,
bool &  found 
) const [inline]

Find a Parameter value in the set, and return its value.

Parameters:
k - Parameter name
default_value - Default value to return if parameter isn't found
found - set to true if the the parameter was found

References verifyParam().

Referenced by SST::Statistics::StatisticOutputTxt::checkOutputParameters(), SST::Statistics::StatisticOutputCSV::checkOutputParameters(), SST::Statistics::StatisticOutputConsole::checkOutputParameters(), and find_string().

static const std::string& SST::Params::getParamName ( uint32_t  id  )  [inline, static]

Given a Parameter Key ID, return the Name of the matching parameter.

Parameters:
id Key ID to look up
Returns:
String name of the parameter

References keyMapReverse.

Referenced by SST::Simulation::performWireUp().

template<class InputIterator >
void SST::Params::insert ( InputIterator  f,
InputIterator  l 
) [inline]

Template function that attemps to insert a range of elements.

Parameters:
f Iterator pointing to the start of the range to be inserted.
l Iterator pointing to the end of the range.

Complexity similar to that of the range constructor.

iterator SST::Params::insert ( iterator  pos,
const value_type x 
) [inline]

Attempts to insert a std::pair into the map.

Parameters:
pos An iterator that serves as a hint as to where the pair should be inserted.
x Pair to be inserted (see std::make_pair for easy creation of pairs).
Returns:
An iterator that points to the element with key of x (may or may not be the pair passed in).

This function is not concerned about whether the insertion took place, and thus does not return a boolean like the single-argument insert() does. Note that the first parameter is only a hint and can potentially improve the performance of the insertion process. A bad hint would cause no gains in efficiency.

Insertion requires logarithmic time (if the hint is not taken).

std::pair<iterator, bool> SST::Params::insert ( const value_type x  )  [inline]

Attempts to insert a std::pair into the map.

Parameters:
x Pair to be inserted (see std::make_pair for easy creation of pairs).
Returns:
A pair, of which the first element is an iterator that points to the possibly inserted pair, and the second is a bool that is true if the pair was actually inserted.

This function attempts to insert a (key, value) pair into the map. A map relies on unique keys and thus a pair is only inserted if its first element (the key) is not already present in the map.

Insertion requires logarithmic time.

size_type SST::Params::max_size (  )  const [inline]

Returns the maximum size of the Params.

Params& SST::Params::operator= ( const Params old  )  [inline]

Map assignment operator.

Parameters:
old A map of identical element and allocator types.

All the elements of x are copied, but unlike the copy constructor, the allocator object is not copied.

mapped_type& SST::Params::operator[] ( const key_type k  )  [inline]

Subscript ( [] ) access to map data.

Parameters:
k The key for which data should be retrieved.
Returns:
A reference to the data of the (key,data) pair.

Allows for easy lookup with the subscript ( [] ) operator. Returns data associated with the key specified in subscript. If the key does not exist, a pair with that key is created using default values, which is then returned.

Lookup requires logarithmic time.

References verifyParam().

void SST::Params::pushAllowedKeys ( const KeySet_t keys  )  [inline]
const_reverse_iterator SST::Params::rbegin (  )  const [inline]

Returns a read-only (constant) reverse iterator that points to the last pair in the Params.

Iteration is done in descending order according to the keys.

reverse_iterator SST::Params::rbegin (  )  [inline]

Returns a read/write reverse iterator that points to the last pair in the Params.

Iteration is done in descending order according to the keys.

const_reverse_iterator SST::Params::rend (  )  const [inline]

Returns a read-only (constant) reverse iterator that points to one before the first pair in the Params.

Iteration is done in descending order according to the keys.

reverse_iterator SST::Params::rend (  )  [inline]

Returns a read/write reverse iterator that points to one before the first pair in the Params.

Iteration is done in descending order according to the keys.

size_type SST::Params::size (  )  const [inline]

Returns the size of the Params.

void SST::Params::verifyParam ( const key_type k  )  const [inline]
Parameters:
k Key to check for validity
Returns:
True if the key is considered allowed

References SST::Output::output(), and SST::Output::STDERR.

Referenced by find(), find_floating(), find_integer(), find_string(), and operator[]().


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

Generated on 14 Sep 2015 for SST by  doxygen 1.6.1