| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

Public Types | Public Member Functions | Private Attributes

# Gaudi::Parsers::PropertyValue Class Reference

`#include <PropertyValue.h>`

Collaboration diagram for Gaudi::Parsers::PropertyValue:
[legend]

List of all members.

## Public Types
typedef boost::shared_ptr < PropertyValue > | SharedPtr
typedef boost::shared_ptr < const PropertyValue > | ConstSharedPtr
typedef boost::scoped_ptr < PropertyValue > | ScopedPtr
typedef boost::scoped_ptr < const PropertyValue > | ConstScopedPtr
typedef boost::variant < std::string, std::vector < std::string >, std::map < std::string, std::string > > | Value
typedef std::vector< std::string > | VectorOfStrings
typedef std::map< std::string, std::string > | MapOfStrings
## Public Member Functions
| PropertyValue (const Value &value, bool is_reference=false)
| PropertyValue (const Value &value, const Position &position, bool is_reference=false)
const Position & | position () const
std::string & | String ()
const std::string & | String () const
VectorOfStrings & | Vector ()
const VectorOfStrings & | Vector () const
MapOfStrings & | Map ()
const MapOfStrings & | Map () const
std::string | ToString () const
bool | HasPosition () const
bool | IsSimple () const
bool | IsVector () const
bool | IsMap () const
bool | IsReference () const
PropertyValue & | operator+= (const PropertyValue &right)
const PropertyValue | operator+ (const PropertyValue &right)
PropertyValue & | operator-= (const PropertyValue &right)
const PropertyValue | operator- (const PropertyValue &right)
## Private Attributes
Value | value_
Position | position_
bool | is_reference_

## Detailed Description

Definition at line 22 of file PropertyValue.h.

## Member Typedef Documentation

typedef boost::scoped_ptr<const PropertyValue> Gaudi::Parsers::PropertyValue::ConstScopedPtr

Definition at line 28 of file PropertyValue.h.

typedef boost::shared_ptr<const PropertyValue> Gaudi::Parsers::PropertyValue::ConstSharedPtr

Definition at line 26 of file PropertyValue.h.

typedef std::map<std::string, std::string> Gaudi::Parsers::PropertyValue::MapOfStrings

Definition at line 33 of file PropertyValue.h.

typedef boost::scoped_ptr<PropertyValue> Gaudi::Parsers::PropertyValue::ScopedPtr

Definition at line 27 of file PropertyValue.h.

typedef boost::shared_ptr<PropertyValue> Gaudi::Parsers::PropertyValue::SharedPtr

Definition at line 25 of file PropertyValue.h.

typedef boost::variant<std::string, std::vector<std::string>, std::map<std::string, std::string> > Gaudi::Parsers::PropertyValue::Value

Definition at line 31 of file PropertyValue.h.

typedef std::vector<std::string> Gaudi::Parsers::PropertyValue::VectorOfStrings

Definition at line 32 of file PropertyValue.h.

## Constructor & Destructor Documentation

Gaudi::Parsers::PropertyValue::PropertyValue | ( | const Value & | value,
|  | bool | is_reference = `false`
| ) |  | `[inline, explicit]`

Definition at line 36 of file PropertyValue.h.

                                  : value_(value), is_reference_(is_reference) {}

Gaudi::Parsers::PropertyValue::PropertyValue | ( | const Value & | value,
|  | const Position & | position,
|  | bool | is_reference = `false`
| ) |  | `[inline]`

Definition at line 38 of file PropertyValue.h.

                                  : value_(value), position_(position),
          is_reference_(is_reference) {}

## Member Function Documentation

bool Gaudi::Parsers::PropertyValue::HasPosition | ( | ) | const`[inline]`

Definition at line 55 of file PropertyValue.h.

    {return position_.Exists();}

bool Gaudi::Parsers::PropertyValue::IsMap | ( | ) | const

Definition at line 25 of file PropertyValue.cpp.

                                      {
      return boost::get<std::map<std::string, std::string> >(&value_) != NULL;
    }

bool Gaudi::Parsers::PropertyValue::IsReference | ( | ) | const`[inline]`

Definition at line 59 of file PropertyValue.h.

    { return is_reference_;};

bool Gaudi::Parsers::PropertyValue::IsSimple | ( | ) | const

Definition at line 17 of file PropertyValue.cpp.

                                         {
      return boost::get<std::string>(&value_) != NULL;
    }

bool Gaudi::Parsers::PropertyValue::IsVector | ( | ) | const

Definition at line 21 of file PropertyValue.cpp.

                                         {
      return boost::get<std::vector<std::string> >(&value_) != NULL;
    }

MapOfStrings& Gaudi::Parsers::PropertyValue::Map | ( | ) | `[inline]`

Definition at line 51 of file PropertyValue.h.

    { return boost::get<MapOfStrings>(value_);}

const MapOfStrings& Gaudi::Parsers::PropertyValue::Map | ( | ) | const`[inline]`

Definition at line 52 of file PropertyValue.h.

    { return boost::get<MapOfStrings>(value_);}

const gp::PropertyValue Gaudi::Parsers::PropertyValue::operator+ | ( | const PropertyValue & | right ) |

Definition at line 68 of file PropertyValue.cpp.

                                                         {
      return PropertyValue(*this) += right;

    }

gp::PropertyValue & Gaudi::Parsers::PropertyValue::operator+= | ( | const PropertyValue & | right ) |

Definition at line 30 of file PropertyValue.cpp.

                                                            {

      if (IsSimple() || IsReference()) {
        throw PropertyValueException::WrongLValue();
      }

      if (IsVector()) {
        if (right.IsSimple()) {
          boost::get<VectorOfStrings>(value_).push_back(
              boost::get<std::string>(right.value_));
          return *this;
        }
        if (right.IsVector()){
          VectorOfStrings& vec = boost::get<VectorOfStrings>(value_);
          BOOST_FOREACH(const std::string& item,
              boost::get<VectorOfStrings>(right.value_)) {
            vec.push_back(item);
          }
          return *this;
        }
        throw PropertyValueException::WrongRValue();
      }

      if (IsMap()) {
        if (!right.IsMap()) {
          throw PropertyValueException::WrongRValue();
        }
        MapOfStrings& map  = boost::get<MapOfStrings>(value_);
        const MapOfStrings& rmap = boost::get<MapOfStrings>(right.value_);
        BOOST_FOREACH(const MapOfStrings::value_type& item, rmap) {
          map.insert(item);
        }
        return *this;
      }
      return *this;
    }

const gp::PropertyValue Gaudi::Parsers::PropertyValue::operator- | ( | const PropertyValue & | right ) |

Definition at line 116 of file PropertyValue.cpp.

                                                         {
      return PropertyValue(*this) -= right;
    }

gp::PropertyValue & Gaudi::Parsers::PropertyValue::operator-= | ( | const PropertyValue & | right ) |

Definition at line 74 of file PropertyValue.cpp.

                                                          {
      if (IsSimple() || IsReference()) {
        throw PropertyValueException::WrongLValue();
      }

      if (IsVector()) {
        VectorOfStrings& vec = Vector();
        if (right.IsSimple()) {
          vec.erase(std::find(vec.begin(), vec.end(), right.String()));
          return *this;
        }

        if (right.IsVector()) {
          const VectorOfStrings& rvec = right.Vector();
          BOOST_FOREACH(const std::string& item, rvec) {
            vec.erase(std::find(vec.begin(), vec.end(), item));
          }
          return *this;
        }
        throw PropertyValueException::WrongRValue();
      }

      if (IsMap()) {
        MapOfStrings& map  = Map();
        if (right.IsSimple()) {
          map.erase(right.String());
          return *this;
        }

        if (right.IsVector()) {
          const VectorOfStrings& rvec = right.Vector();
          BOOST_FOREACH(const std::string& item, rvec) {
            map.erase(item);
          }
          return *this;
        }
        throw PropertyValueException::WrongRValue();
      }
      throw PropertyValueException::WrongLValue();
    }

const Position& Gaudi::Parsers::PropertyValue::position | ( | ) | const`[inline]`

Definition at line 42 of file PropertyValue.h.

    { return position_;}

const std::string& Gaudi::Parsers::PropertyValue::String | ( | ) | const`[inline]`

Definition at line 45 of file PropertyValue.h.

    { return boost::get<std::string>(value_);}

std::string& Gaudi::Parsers::PropertyValue::String | ( | ) | `[inline]`

Definition at line 44 of file PropertyValue.h.

    { return boost::get<std::string>(value_);}

std::string Gaudi::Parsers::PropertyValue::ToString | ( | ) | const

Definition at line 120 of file PropertyValue.cpp.

                                              {
      if  (IsReference()) {
        const std::vector<std::string>*
           value = boost::get<std::vector<std::string> >(&value_);
        assert(value != NULL);
        if (value->at(0) != "") {
          return "@"+value->at(0)+"."+value->at(1);
        } else {
          return "@"+value->at(0);
        }
      }
      if (const std::string* value = boost::get<std::string>(&value_)) {
        return *value;
      } else if (const std::vector<std::string>*
          value = boost::get<std::vector<std::string> >(&value_)) {
        std::string result = "[";
        std::string delim = "";
        BOOST_FOREACH(const std::string& in, *value) {
          result += delim + in;
          delim = ", ";
        }
        return result+"]";
      } else if (const std::map<std::string, std::string>*
          value = boost::get<std::map<std::string, std::string> >(&value_)) {
        std::string result = "{";
        std::string delim = "";
        typedef std::pair<std::string, std::string> pair_t;
        BOOST_FOREACH(const pair_t& in, *value) {
          result += delim + in.first + ":" + in.second;
          delim = ", ";
        }
        return result+"}";
      }
      assert(false);
      // @todo Check the validity of this logic
      return std::string(); // avoid compilation warning
    }

const VectorOfStrings& Gaudi::Parsers::PropertyValue::Vector | ( | ) | const`[inline]`

Definition at line 48 of file PropertyValue.h.

                                            {
        return boost::get<VectorOfStrings>(value_);}

VectorOfStrings& Gaudi::Parsers::PropertyValue::Vector | ( | ) | `[inline]`

Definition at line 47 of file PropertyValue.h.

    { return boost::get<VectorOfStrings>(value_);}

## Member Data Documentation

bool Gaudi::Parsers::PropertyValue::is_reference_`[private]`

Definition at line 72 of file PropertyValue.h.

Position Gaudi::Parsers::PropertyValue::position_`[private]`

Definition at line 71 of file PropertyValue.h.

Value Gaudi::Parsers::PropertyValue::value_`[private]`

Definition at line 70 of file PropertyValue.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r4/GaudiSvc/src/JobOptionsSvc/PropertyValue.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r4/GaudiSvc/src/JobOptionsSvc/PropertyValue.cpp

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines