Fairport
v1.0.38
|
The node implementation. More...
#include <node.h>
Public Member Functions | |
node_impl (const shared_db_ptr &db, const node_info &info) | |
Constructor for top level nodes. | |
node_impl (const std::tr1::shared_ptr< node_impl > &container_node, const subnode_info &info) | |
Constructor for subnodes. | |
node_id | get_id () const |
Get the id of this node. | |
block_id | get_data_id () const |
Get the block_id of the data block of this node. | |
block_id | get_sub_id () const |
Get the block_id of the subnode block of this node. | |
node_id | get_parent_id () const |
Get the parent id. | |
bool | is_subnode () const |
Tells you if this is a subnode. | |
std::tr1::shared_ptr< data_block > | get_data_block () const |
Returns the data block associated with this node. | |
std::tr1::shared_ptr < subnode_block > | get_subnode_block () const |
Returns the subnode block associated with this node. | |
shared_db_ptr | get_db () const |
Returns the database containing this node. | |
size_t | read (std::vector< byte > &buffer, ulong offset) const |
Read data from this node. | |
template<typename T > | |
T | read (ulong offset) const |
Read data from this node. | |
size_t | read (std::vector< byte > &buffer, uint page_num, ulong offset) const |
Read data from this node. | |
template<typename T > | |
T | read (uint page_num, ulong offset) const |
Read data from a specific block on this node. | |
size_t | read_raw (byte *pdest_buffer, size_t size, ulong offset) const |
Read data from this node. | |
size_t | size () const |
Returns the size of this node. | |
size_t | get_page_size (uint page_num) const |
Returns the size of a page in this node. | |
uint | get_page_count () const |
Returns the number of pages in this node. | |
const_subnodeinfo_iterator | subnode_info_begin () const |
Returns an iterator positioned at first subnodeinfo. | |
const_subnodeinfo_iterator | subnode_info_end () const |
Returns an iterator positioned past the last subnodeinfo. | |
node | lookup (node_id id) const |
Lookup a subnode by node id. |
The node implementation.
The node class is really divided into two classes, node and node_impl. The purpose of this design is to allow a node to conceptually "outlive" the stack based object encapsulating it. This is necessary if subobjects are opened which still need to refer to their parent. This is accomplished in this case, like others, via having a thin stack based object (node) with a shared pointer to the implemenetation object (node_impl). Subnodes will grab a shared_ptr ref to the parents node_impl.
See the documentation for node to read more about what a node is.
The interface of node_impl follows closely that of node; differing mainly in the construction and destruction semantics plus the addition of some convenience functions.
fairport::node_impl::node_impl | ( | const shared_db_ptr & | db, |
const node_info & | info | ||
) | [inline] |
fairport::node_impl::node_impl | ( | const std::tr1::shared_ptr< node_impl > & | container_node, |
const subnode_info & | info | ||
) | [inline] |
std::tr1::shared_ptr<data_block> fairport::node_impl::get_data_block | ( | ) | const [inline] |
fairport::block_id fairport::node_impl::get_data_id | ( | ) | const [inline] |
shared_db_ptr fairport::node_impl::get_db | ( | ) | const [inline] |
node_id fairport::node_impl::get_id | ( | ) | const [inline] |
fairport::uint fairport::node_impl::get_page_count | ( | ) | const [inline] |
size_t fairport::node_impl::get_page_size | ( | uint | page_num | ) | const [inline] |
node_id fairport::node_impl::get_parent_id | ( | ) | const [inline] |
fairport::block_id fairport::node_impl::get_sub_id | ( | ) | const [inline] |
std::tr1::shared_ptr<subnode_block> fairport::node_impl::get_subnode_block | ( | ) | const [inline] |
bool fairport::node_impl::is_subnode | ( | ) | const [inline] |
fairport::node fairport::node_impl::lookup | ( | node_id | id | ) | const [inline] |
Read data from this node.
Fills the specified buffer with data starting at the specified offset. The size of the buffer indicates how much data to read.
[in,out] | buffer | The buffer to fill |
[in] | offset | The location to read from |
T fairport::node_impl::read | ( | ulong | offset | ) | const [inline] |
size_t fairport::node_impl::read | ( | std::vector< byte > & | buffer, |
uint | page_num, | ||
ulong | offset | ||
) | const [inline] |
Read data from this node.
Fills the specified buffer with data on the specified page at the specified offset. The size of teh buffer indicates how much data to read.
[in,out] | buffer | The buffer to fill |
[in] | page_num | The page to read from |
[in] | offset | The location to read from |
Read data from a specific block on this node.
T | The type to read |
[in] | page_num | The block (ordinal) to read data from |
[in] | offset | The offset into that block to read from |
size_t fairport::node_impl::size | ( | ) | const [inline] |
fairport::const_subnodeinfo_iterator fairport::node_impl::subnode_info_begin | ( | ) | const [inline] |
fairport::const_subnodeinfo_iterator fairport::node_impl::subnode_info_end | ( | ) | const [inline] |