conf::ConfSet< T > Class Template Reference

Class implementing a set directive type. More...

#include <directives.h>

Inheritance diagram for conf::ConfSet< T >:

conf::ConfValue< T > conf::ConfDir List of all members.

Public Types

typedef std::map< std::string,
T, misc::insensitive_less
BitList

Public Member Functions

 ConfSet (std::string const &name, bool reloadable)
 Constructor setting the directive name.
 ConfSet (std::string const &name, T const &defval, bool reloadable)
 Constructor setting the directive name and default value.
 ConfSet (ConfSet const &cd)
 Copy constructor.
virtual ConfSet< T > & operator= (ConfSet< T > const &right)
 Assignment operator.
 operator T const & () const
 Conversion operator.
virtual char const * label (size_t index) const
 Implements ConfDir::label().

Protected Member Functions

virtual bool add (Conf &conf)=0
 Adds valid bits to the list.
virtual bool assign (Conf &conf, unsigned short count, std::string const params[])
 Sets the value.

Protected Attributes

BitList m_bits
 The list of bits.

Detailed Description

template<class T = u_int32_t>
class conf::ConfSet< T >

This class is used to store "bits" in 32-bits int values. Each bit has a name that will be used in configuration to set or clear the bit to and from the value.

For example, for a bit named "SOMETHING", if a parameter "+SOMETHING" is set to a directive of this type, then the SOMETHING bit will be set to the value, and if a parameter "-SOMETHING" is set to a directive of this type, then the SOMETHING bit will be cleared. Of course, directives of this type may be set multiple times to set or clear bits.

This class must not be used directly. Instead, it must be inherited, and the add() function should be overriden to add all possible bits to m_bits.

The template parameter is the type in which bits will be stored. A conversion operator to this type is provided for easy access to the value.


Member Function Documentation

template<class T = u_int32_t>
virtual bool conf::ConfSet< T >::add ( Conf conf  )  [protected, pure virtual]

This function adds valid bits to the m_bits list. It must be defined in an inherited class. Example of adding a bit to the list. m_bits["SOMETHING"] = 0x00080000;

Parameters:
[in] conf The Conf object that called the set() function.
Returns:
true if successful, false otherwise. You must log an error message through conf.error() in that case.

template<class T>
bool conf::ConfSet< T >::assign ( Conf conf,
unsigned short  count,
std::string const  params[] 
) [inline, protected, virtual]

Transforms the string array passed by the parser into the directive's value. This function must ensure that the value is valid through a call to check() before setting it (you don't need to set m_value_set to true, this will be handled by set() when the function returns successfully).

Parameters:
[in] conf The Conf object that called set().
[in] count Number of parameters in params.
[in] params Parameters passed to the directive (NULL if count is 0).
Returns:
true if the function is successful, false otherwise (conf.error() should have be called with an appropriate error message in that case).

Implements conf::ConfValue< T >.


The documentation for this class was generated from the following file:
Generated on Wed Aug 15 00:37:22 2007 for Epona API by  doxygen 1.5.2