libmoost
moost::kvds::KvdsPodType< T > Class Template Reference

*** This class is NOT thread safe *** More...

#include <kvds_pod_type.hpp>

List of all members.

Classes

class  vector_type
 To support getall and putall we need to handle vectors of kvds_type. More...

Public Types

typedef T kvds_type

Public Member Functions

 BOOST_STATIC_ASSERT (boost::is_pod< T >::value)
 This particular KvdsType only supports pod types.
 KvdsPodType (T &t)
 c_tor that takes a reference to the real type being represented
 KvdsPodType (KvdsPodType const &t)
 cc_tor
KvdsPodTypeoperator= (KvdsPodType const &rhs)
 Assignment.
bool operator== (T const &t) const
 basic comparators
bool operator!= (T const &t) const
bool operator== (KvdsPodType< T > const &t) const
bool operator!= (KvdsPodType< T > const &t) const
size_t size () const
 Return the size of the const byte buffer.
kvds_type const * operator& () const
 Return pointer to const byte buffer.
kvds_typeoperator* () const
 Return a reference to the type associated with the const byte buffer.
size_t & size ()
 Return the size of the mutable buffer.
kvds_typeoperator& ()
 Return pointer to mutable buffer.
kvds_typeoperator* ()

Private Attributes

kvds_typet_
size_t size_

Detailed Description

template<typename T>
class moost::kvds::KvdsPodType< T >

*** This class is NOT thread safe ***

This class represents a generic wrapper for Plain Old Data types. If you wish to support other types you need to implement your own version of this class that can serialise and deserialise the object in question as well as a vector of objects to facilitate support for getall() & putall(). Serialising integral types is simple since we can just read/write to them directly (assuming endianess isn't a factor) but with custom types it will be necessary to provide a mutable and non-mutable byte representation of the actual type that can be written to and read from the database. In the case of, say, a vector this would just be the internal buffer given the vectors internal representation guarantees but in the case of, say, a string this is likely to require a seperate byte buffer be maintained that is used to reassemble the string from a mutable action. This is likely to be no more complex than using the vector<char> as a buffer and copying to/from the string. KvdsType

Definition at line 59 of file kvds_pod_type.hpp.


Member Typedef Documentation

template<typename T>
typedef T moost::kvds::KvdsPodType< T >::kvds_type

Definition at line 62 of file kvds_pod_type.hpp.


Constructor & Destructor Documentation

template<typename T>
moost::kvds::KvdsPodType< T >::KvdsPodType ( T &  t) [inline]

c_tor that takes a reference to the real type being represented

Definition at line 68 of file kvds_pod_type.hpp.

template<typename T>
moost::kvds::KvdsPodType< T >::KvdsPodType ( KvdsPodType< T > const &  t) [inline]

cc_tor

Definition at line 71 of file kvds_pod_type.hpp.


Member Function Documentation

template<typename T>
moost::kvds::KvdsPodType< T >::BOOST_STATIC_ASSERT ( boost::is_pod< T >::value  )

This particular KvdsType only supports pod types.

template<typename T>
bool moost::kvds::KvdsPodType< T >::operator!= ( T const &  t) const [inline]

Definition at line 82 of file kvds_pod_type.hpp.

template<typename T>
bool moost::kvds::KvdsPodType< T >::operator!= ( KvdsPodType< T > const &  t) const [inline]

Definition at line 84 of file kvds_pod_type.hpp.

template<typename T>
kvds_type const* moost::kvds::KvdsPodType< T >::operator& ( ) const [inline]

Return pointer to const byte buffer.

Definition at line 97 of file kvds_pod_type.hpp.

template<typename T>
kvds_type* moost::kvds::KvdsPodType< T >::operator& ( ) [inline]

Return pointer to mutable buffer.

Definition at line 117 of file kvds_pod_type.hpp.

template<typename T>
kvds_type& moost::kvds::KvdsPodType< T >::operator* ( ) const [inline]

Return a reference to the type associated with the const byte buffer.

Definition at line 100 of file kvds_pod_type.hpp.

template<typename T>
kvds_type& moost::kvds::KvdsPodType< T >::operator* ( ) [inline]

Return a reference to the type associated with the mutable buffer. If necessary the type should be assembled from the mutable byte buffer. This will be called after any operations that might have mutated the buffer to give the KvdsType a chance to assemble the type. If the buffer size not a divisor equal to sizeof(kvds_type) an exception should thrown. Obviously, since this operator may be called a number of times it should only reassemble the buffer if it's been modified. This could have been called as a seperate function call but if this call was forgotten the result from this operator would not be as expected and since there is only a trivial overhead in performing the necessary check to see if the buffer needs assembling it was deemed worth the cost for the sake of consistant behavior when calling this operator was worth it.

Definition at line 131 of file kvds_pod_type.hpp.

template<typename T>
KvdsPodType& moost::kvds::KvdsPodType< T >::operator= ( KvdsPodType< T > const &  rhs) [inline]

Assignment.

Definition at line 74 of file kvds_pod_type.hpp.

template<typename T>
bool moost::kvds::KvdsPodType< T >::operator== ( T const &  t) const [inline]

basic comparators

Definition at line 81 of file kvds_pod_type.hpp.

template<typename T>
bool moost::kvds::KvdsPodType< T >::operator== ( KvdsPodType< T > const &  t) const [inline]

Definition at line 83 of file kvds_pod_type.hpp.

template<typename T>
size_t moost::kvds::KvdsPodType< T >::size ( ) const [inline]

Return the size of the const byte buffer.

Const operations

These members handle the case where the type being represented is an immutable reference. In this case all we need do is provide an immutable byte buffer and size of that buffer, which contains a serialise form of the represented type for the kvds engine to store.

Definition at line 94 of file kvds_pod_type.hpp.

template<typename T>
size_t& moost::kvds::KvdsPodType< T >::size ( ) [inline]

Return the size of the mutable buffer.

Non-const operations

These members handle the case where the type being represented is a mutable reference. In this case we need to provide a mutable byte buffer and size of that buffer, which contains a serialise form of the represented type for the kvds engine to store or modify. In the case where the buffer is modified the type needs to be reassembled from the modified buffer so to facilitate this Kvds will call the operator, which will give the KvdsType the opportunity to update the value and size of the actual type being represented.

Definition at line 114 of file kvds_pod_type.hpp.


Member Data Documentation

template<typename T>
size_t moost::kvds::KvdsPodType< T >::size_ [private]

Definition at line 203 of file kvds_pod_type.hpp.

template<typename T>
kvds_type& moost::kvds::KvdsPodType< T >::t_ [private]

Definition at line 202 of file kvds_pod_type.hpp.


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