Pothos
0.7.0-gf7fbae99
The Pothos dataflow programming software suite
|
#include <Object.hpp>
Classes | |
struct | Emplace |
Emplace dummy type to pass type to Object emplacement constructor. More... | |
Public Member Functions | |
Object (void) | |
Object (const Object &obj) | |
Object (Object &&obj) noexcept | |
template<typename ValueType , typename = Pothos::Util::disable_if_same<Object, ValueType>> | |
Object (ValueType &&value) | |
template<typename ValueType , typename... Args> | |
Object (Emplace< ValueType >, Args &&... args) | |
Object (const char *) | |
~Object (void) | |
Object & | operator= (const Object &rhs) |
Object & | operator= (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 & | ref (void) |
template<typename ValueType > | |
ValueType | convert (void) const |
template<typename ValueType > | |
operator ValueType (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) |
template<typename ValueType , typename... Args> | |
static Object | emplace (Args &&... args) |
static bool | canConvert (const std::type_info &srcType, const std::type_info &dstType) |
Public Attributes | |
Detail::ObjectContainer * | _impl |
Private implementation details. More... | |
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.
Pothos::Object::Object | ( | void | ) |
Create a null Object.
Pothos::Object::Object | ( | const Object & | obj | ) |
|
inlinenoexcept |
|
explicit |
Create a new Object from an an arbitrary value.
value | the data to store internally |
|
explicit |
|
inlineexplicit |
Create an Object of type std::string from a C-style string.
Pothos::Object::~Object | ( | void | ) |
bool Pothos::Object::canConvert | ( | const std::type_info & | type | ) | const |
Is the conversion of this Object to specified type possible?
type | the desired typeid in question |
|
static |
Is the conversion from source type to destination type possible?
srcType | the type of the conversion input |
dstType | the type of the conversion output |
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.
ObjectCompareError | when the compare isnt possible |
other | the other proxy object to compare against |
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.
ObjectConvertError | if object cannot be safe casted |
Object Pothos::Object::convert | ( | const std::type_info & | type | ) | const |
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.
ObjectSerializeError | if the type is not registered |
is | the input stream holding serialized data |
|
static |
Create an object with emplacement construction. The make method allows users to pass an explicit type, and an arbitrary number of constructor arguments which will be forwarded to the type T constructor.
ValueType | the internal type held by the new Object |
args | the constructor arguments for type ValueType |
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.
const ValueType & Pothos::Object::extract | ( | void | ) | const |
Get a const reference to the internal data. The requested cast type must exactly match the type().
ObjectConvertError | if object type != ValueType |
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.
|
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.
value | a value of arbitrary type to put in an Object |
|
explicit |
Does the object hold a value?
Pothos::Object::operator ValueType | ( | void | ) | const |
Templated conversion operator to assign Object to a target type.
ObjectConvertError | if object cannot be safe casted |
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.
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.
ValueType & Pothos::Object::ref | ( | void | ) |
Get a non-const reference to the internal data. The requested cast type must exactly match the type(). The Object must be unique and have only one reference.
Note: The Object container class is usually immutable unless the caller has sole ownership of the object. Typical use cases for mutability might include object initialization, object de-serialization, and rvalue m when object is a return value.
ObjectConvertError | if object type != ValueType |
ObjectConvertError | if multiple reference counts |
std::ostream& Pothos::Object::serialize | ( | std::ostream & | os | ) | const |
Serialize the contents of the object into a stream.
ObjectSerializeError | if the type is not registered |
os | the output stream for the serialized data |
std::string Pothos::Object::toString | ( | void | ) | const |
Get a printable string representation for this Object. The string formatting depends upon the contained value.
|
inline |
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?
Detail::ObjectContainer* Pothos::Object::_impl |
Private implementation details.