rwsf::Attribute rwsf::HandleBase
#include <rwsf/core/Attribute.h>
rwsf::Attribute provides a wrapper around objects of any type. rwsf::Attribute contains a single object by value. The contained object must provide a default constructor, a copy constructor, and an assignment operator. The copy constructor must not invalidate the original object. The class provides an inserter template to copy values into an instance and an extractor template to copy values out of an instance.
An instance of rwsf::Attribute is the value of the key/value pair in several Hydra Core and Web Services Fabrication classes, such as rwsf::CallInfo and rwsf::NamedObject.
rwsf::Attribute makes use of the handle/body idiom in which rwsf::Attribute is the handle, and rwsf::AttributeImp<T> is the body.
Templatized insertion and extraction operators are provided for moving typed objects into and out of an rwsf::Attribute instance.
enum Lifetime { Transient = 1, Persistent = 2 };
Enumeration to determine whether or not this attribute should be persisted.
Attribute(Lifetime l = Transient);
Constructs an invalid instance of rwsf::Attribute, with a default lifetime of Transient. Using the insertion operator, a typed object must be inserted into this object before it is usable.
Attribute(const Attribute& rhs);
Copy constructor. This instance will be a handle to the same value as rhs..Attaches to and increments the reference count on rhs's body.
virtual ~Attribute();
Destructor. Detaches from the current body (if any), decrements its reference count, and deletes it if there are no other references.
bool isTransient() const;
Returns true if self is transient. Otherwise, returns false.
void setTransient(bool isTransient);
Determines whether this rwsf::Attribute is transient or persistent. The default is true (transient).
template<class T> static T& value(Attribute& attr);
Returns a reference to the typed value held in self. If this attribute does not hold an object of type T, an exception is thrown.
template <class T> static const T& value(const Attribute& attr);
Returns a const reference to the typed value held in self. If this attribute does not hold an object of type T, an exception is thrown.
Attribute& operator=(const Attribute& rhs);
Assignment operator. This instance will hold the same value as rhs.
template<class T> void operator<<(Attribute& attr, const T& value);
Insertion operator. Inserts a copy of value into attr. Note that T must be a single object rather than an array, and that the operator uses the exact type of T. In particular, an attribute cannot hold an array of char. Instead, use an std::string:
Attribute attr; attr << std::string("Inserts an std::string.");
template<class T> void operator>>(const Attribute& attr, T& value);
Extraction operator. Extracts the value of stored in attr and copies it into value. If attr does not contain a value, value is unchanged. Note that the type of value must exactly match the type inserted into attr. Otherwise, the operator throws an exception of type rwsf::Exception.
©2004-2007 Copyright Quovadx, Inc. All Rights Reserved.
Quovadx and Rogue Wave are registered trademarks and HydraSDO is a trademark of Quovadx, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.