Pothos  0.4.0-gd11861cd
The Pothos dataflow programming software suite
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Pothos::Object Class Reference

#include <Object.hpp>

Inheritance diagram for Pothos::Object:
Inheritance graph
[legend]

Public Member Functions

 Object (void)
 
 Object (const Object &obj)
 
 Object (Object &obj)
 
 Object (Object &&obj)
 
 Object (const Object &&obj)
 
template<typename ValueType >
 Object (ValueType &&value)
 
virtual ~Object (void)
 
Objectoperator= (const Object &rhs)
 
Objectoperator= (Object &&rhs)
 
 operator bool (void) const
 
bool unique (void) const
 
const std::type_info & type (void) const
 
template<typename ValueType >
const ValueType & extract (void) const
 
template<typename ValueType >
ValueType convert (void) const
 
Object convert (const std::type_info &type) const
 
bool canConvert (const std::type_info &type) const
 
std::ostream & serialize (std::ostream &os) const
 
std::istream & deserialize (std::istream &is)
 
int compareTo (const Object &other) const
 
size_t hashCode (void) const
 
std::string toString (void) const
 
std::string getTypeString (void) const
 
bool equals (const Object &obj) const
 
bool operator< (const Object &obj) const
 
bool operator> (const Object &obj) const
 

Static Public Member Functions

template<typename ValueType >
static Object make (ValueType &&value)
 
static bool canConvert (const std::type_info &srcType, const std::type_info &dstType)
 

Public Attributes

Detail::ObjectContainer * _impl
 Private implementation details. More...
 

Detailed Description

Object is a general type capable of storing arbitrary data types. When an Object instance is copied, the internal data is not copied. The internal data is only deleted when all Object copies are gone.

Constructor & Destructor Documentation

Pothos::Object::Object ( void  )

Create a null Object.

Pothos::Object::Object ( const Object obj)

Copy constructor for Object – does not copy the internal data. Both obj and the resulting Object will point to the same data.

Parameters
objanother Object
Pothos::Object::Object ( Object obj)

Copy constructor for Object – does not copy the internal data. Both obj and the resulting Object will point to the same data.

Parameters
objanother Object
Pothos::Object::Object ( Object &&  obj)

Move constructor for Object. The contents of obj will be moved to the new Object.

Parameters
objanother Object
Pothos::Object::Object ( const Object &&  obj)

Move constructor for Object. The contents of obj will be moved to the new Object.

Parameters
objanother Object
template<typename ValueType >
Pothos::Object::Object ( ValueType &&  value)
explicit

Create a new Object from an an arbitrary value.

Parameters
valuethe data to store internally
virtual Pothos::Object::~Object ( void  )
virtual

Destructor for Object. If this Object holds the only copy of the internal data, then the internal data will be deleted in the destructor.

Member Function Documentation

bool Pothos::Object::canConvert ( const std::type_info &  type) const

Is the conversion of this Object to specified type possible?

Parameters
typethe desired typeid in question
Returns
true if the conversion is possible.
static bool Pothos::Object::canConvert ( const std::type_info &  srcType,
const std::type_info &  dstType 
)
static

Is the conversion from source type to destination type possible?

Parameters
srcTypethe type of the conversion input
dstTypethe type of the conversion output
Returns
true if the conversion is possible.
int Pothos::Object::compareTo ( const Object other) const

Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Exceptions
ObjectCompareErrorwhen the compare isnt possible
Parameters
otherthe other proxy object to compare against
Returns
an int representing less than, equal to, or greater than
template<typename ValueType >
ValueType Pothos::Object::convert ( void  ) const

Convert performs a safe conversion that respects the value when an exact type conversion is not required or wanted. For example, the object may contain an int, we want a long.

Exceptions
ObjectConvertErrorif object cannot be safe casted
Returns
a value that represents the internal data
Object Pothos::Object::convert ( const std::type_info &  type) const

Convert to a new Object that will be of the type specified.

Exceptions
ObjectConvertErrorif object cannot be safe casted
Parameters
typethe desired type held by the output Object
Returns
a new Object that can be extracted to type
std::istream& Pothos::Object::deserialize ( std::istream &  is)

Deserialize the stream into the contents of this Object. Only make this call on a null object.

Exceptions
ObjectSerializeErrorif the type is not registered
Parameters
isthe input stream holding serialized data
Returns
a reference to the input stream
bool Pothos::Object::equals ( const Object obj) const

Value-based equality operator. When supported, the implementation uses the compareTo() method. Otherwise, the hash codes are compared for checking equality.

template<typename ValueType >
const ValueType & Pothos::Object::extract ( void  ) const

Cast the internal data to an arbitrary type. The requested cast type must exactly match the type().

Exceptions
ObjectConvertErrorif object type != ValueType
Returns
a const reference to the internal data
std::string Pothos::Object::getTypeString ( void  ) const

Get a printable string representing the type held by this Object.

size_t Pothos::Object::hashCode ( void  ) const

Get a hash code for the contained object. The hash code should be identical for equivalent objects.

template<typename ValueType >
Object Pothos::Object::make ( ValueType &&  value)
static

Create an object where type can be explicitly specified. The make method allows users to pass an explicit type, which is not possible using the templated constructor. Also, the make method can create an Object containing another object; which is not possible with constructors because the copy constructor.

Parameters
valuea value of arbitrary type to put in an Object
Returns
a new Object containing a copy of the specified value
Pothos::Object::operator bool ( void  ) const
explicit

Does the object hold a value?

Returns
true if the container is non-empty
bool Pothos::Object::operator< ( const Object obj) const

Less than comparable operator. When supported, the implementation uses the compareTo() method. Otherwise, the hash codes are compared for sorting purposes.

Object& Pothos::Object::operator= ( const Object rhs)

Object copy assignment. This Object will store a copy of the internal data in rhs. The old internal data will be released, and deleted if last.

Parameters
rhsanother Object
Object& Pothos::Object::operator= ( Object &&  rhs)

Object move assignment. The contents of rhs will be moved to this Object. The old internal data will be released, and deleted if last.

Parameters
rhsanother Object
bool Pothos::Object::operator> ( const Object obj) const

Greater than comparable operator. When supported, the implementation uses the compareTo() method. Otherwise, the hash codes are compared for sorting purposes.

std::ostream& Pothos::Object::serialize ( std::ostream &  os) const

Serialize the contents of the object into a stream.

Exceptions
ObjectSerializeErrorif the type is not registered
Parameters
osthe output stream for the serialized data
Returns
a reference to the output stream
std::string Pothos::Object::toString ( void  ) const

Get a printable string representation for this Object. The string formatting depends upon the contained value.

const std::type_info& Pothos::Object::type ( void  ) const

Get the type of the internal data. The call returns typeid(NullObject) if the Object is null.

bool Pothos::Object::unique ( void  ) const

Is the Object unique?

Returns
true if this is the only reference

Member Data Documentation

Detail::ObjectContainer* Pothos::Object::_impl

Private implementation details.


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