Back to index

nux  3.0.0
Public Member Functions | Private Types | Private Member Functions | Private Attributes
nux::Introspectable Class Reference

#include <Property.h>

Inheritance diagram for nux::Introspectable:
Inheritance graph
[legend]
Collaboration diagram for nux::Introspectable:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Introspectable ()
bool SetProperty (std::string const &name, const char *value)
 If the property was not able to be set with the value, the method returns false.
template<typename T >
bool SetProperty (std::string const &name, T const &value)
template<typename T >
GetProperty (std::string const &name, T *foo=0)
void AddProperty (std::string const &name, PropertyBase *property)

Private Types

typedef std::map< std::string,
PropertyBase * > 
PropertyContainer

Private Member Functions

 Introspectable (Introspectable const &)
Introspectableoperator= (Introspectable const &)

Private Attributes

PropertyContainer properties_

Detailed Description

Definition at line 199 of file Property.h.


Member Typedef Documentation

typedef std::map<std::string, PropertyBase*> nux::Introspectable::PropertyContainer [private]

Definition at line 223 of file Property.h.


Constructor & Destructor Documentation

Definition at line 251 of file Property-inl.h.

{}

Member Function Documentation

void nux::Introspectable::AddProperty ( std::string const &  name,
PropertyBase property 
) [inline]

Definition at line 254 of file Property-inl.h.

{
  // check to see if it exists and if it does barf horribly as we can't
  // have two properties with the same name;
  properties_[name] = property;
}

Here is the caller graph for this function:

template<typename T >
T nux::Introspectable::GetProperty ( std::string const &  name,
T *  foo = 0 
)

Definition at line 285 of file Property-inl.h.

{
  PropertyContainer::iterator i = properties_.find(name);
  if (i == properties_.end())
    return T();

  std::string s = i->second->GetSerializedValue();
  std::pair<T, bool> result = type::PropertyTrait<T>::from_string(s);
  // If this is called with a template type that the property does not
  // support nice conversion to, you'll get no error, but will get
  // a default constructed T.  We could use an exception here.
  return result.first;
}
Introspectable& nux::Introspectable::operator= ( Introspectable const &  ) [private]
bool nux::Introspectable::SetProperty ( std::string const &  name,
const char *  value 
) [inline]

If the property was not able to be set with the value, the method returns false.

Definition at line 262 of file Property-inl.h.

{
  PropertyContainer::iterator i = properties_.find(name);
  if (i == properties_.end())
    return false;
  else
    return i->second->SetValue(value);
}
template<typename T >
bool nux::Introspectable::SetProperty ( std::string const &  name,
T const &  value 
)

Definition at line 273 of file Property-inl.h.

{
  PropertyContainer::iterator i = properties_.find(name);
  if (i == properties_.end())
    return false;
  else
  {
    return i->second->SetValue(type::PropertyTrait<T>::to_string(value));
  }
}

Member Data Documentation

Definition at line 224 of file Property.h.


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