BIndexedDataNode Class Reference
[Data Model]

#include <storage/IndexedDataNode.h>

Inheritance diagram for BIndexedDataNode:

BMetaDataNode BIndexedIterable SDatumGeneratorInt BGenericNode BGenericIterable SAtom BnNode BnIterable SSQLBuilder INode BBinder IIterable BBinder IInterface IBinder IInterface IBinder SAtom SAtom SAtom SAtom BIndexedTableNode::RowNode BSchemaDatabaseNode BSchemaTableNode::RowNode BStructuredNode List of all members.

Detailed Description

An implementation of INode that holds an array of data, identified by index.

The class derives from BMetaDataNode, providing a more concrete implementation for nodes that hold an indexed array of simple data. It implements BMetaDataNode::LookupEntry() for you. It takes care of pushing the INode::NodeChanged and INode::EntryModified events, through use of SDatumGeneratorInt::ReportChangeAtLocked().

The class derives from BIndexedIterable, providing index-based iterators over the node data. It implements BIndexedIterable::EntryAtLocked() for you. It calls BGenericIterable::PushIteratorChangedLocked() as needed when its data changes, through use of SDatumGeneratorInt::ReportChangeAtLocked().

The class derives from SDatumGeneratorInt to assist in the implementation of BMetaDataNode and BIndexedIterable.

You must still implement the methods BIndexedIterable::CountEntriesLocked(), SDatumGeneratorInt::ValueAtLocked(), SDatumGeneratorInt::StoreValueAtLocked(), and the new virtuals EntryIndexOfLocked() and EntryNameAtLocked().


Implementation

Provide default implementation based on new capabilities.

virtual bool AllowDataAtLocked (size_t index) const
 Control whether a client will receive data for INode::REQUEST_DATA.
virtual status_t EntryAtLocked (const sptr< IndexedIterator > &it, size_t index, uint32_t flags, SValue *key, SValue *entry)
 Implement using EntryNameAtLocked() and FetchEntryAtLocked().
status_t FetchEntryAtLocked (size_t index, uint32_t flags, SValue *entry)
 Use ValueAtLocked() to retrieve the entry and DatumAtLocked() if INode::REQUEST_DATA is set.
virtual status_t LookupEntry (const SString &entry, uint32_t flags, SValue *node)
 Implement using EntryIndexOfLocked() and FetchEntryAtLocked().
virtual void ReportChangeAtLocked (size_t index, const sptr< IBinder > &editor, uint32_t changes, off_t start=-1, off_t length=-1)
 Also push INode::NodeChanged, INode::EntryModified, and IIterator::IteratorChanged events.

Bookkeeping

Creation, destruction, locking, etc.

 BIndexedDataNode (const SContext &context, uint32_t mode=IDatum::READ_WRITE)
 BIndexedDataNode (uint32_t mode=IDatum::READ_WRITE)
SContext Context ()
 Disambiguate.
virtual SValue Inspect (const sptr< IBinder > &caller, const SValue &which, uint32_t flags)
 Make both INode and IIterable accessible.
virtual lock_status_t Lock () const
 Disambiguate.
virtual void Unlock () const
 Disambiguate.
virtual ~BIndexedDataNode ()

Other Pure Virtuals

Purely informative definition of remaining pure virtuals from the base classes.

virtual size_t CountEntriesLocked () const =0
 From BIndexedIterable::CountEntriesLocked().
virtual status_t StoreValueAtLocked (size_t index, const SValue &value)=0
 From SDatumGeneratorInt::StoreValueAtLocked().
virtual SValue ValueAtLocked (size_t index) const =0
 From SDatumGeneratorInt::ValueAtLocked().

New Pure Virtuals

New virtuals that must be implemented by derived classes, to associated entry names with indices.

virtual ssize_t EntryIndexOfLocked (const SString &entry) const =0
 Return the index for an entry name in the node.
virtual SString EntryNameAtLocked (size_t index) const =0
 Return the name of an entry at a given index.


Constructor & Destructor Documentation

BIndexedDataNode uint32_t  mode = IDatum::READ_WRITE  ) 
 

BIndexedDataNode const SContext context,
uint32_t  mode = IDatum::READ_WRITE
 

~BIndexedDataNode  )  [protected, virtual]
 


Member Function Documentation

bool AllowDataAtLocked size_t  index  )  const [virtual]
 

Control whether a client will receive data for INode::REQUEST_DATA.

The default implementation calls SizeAtLocked() to disable data copying if the data size > 2048.

Note:
If your data at an index is actually an object, AllowDataAtLocked() must return true so that that object will be returned, not an IDatum wrapping it.

SContext Context  )  [inline]
 

Disambiguate.

Reimplemented in BSchemaDatabaseNode, and BSchemaTableNode::RowNode.

virtual size_t CountEntriesLocked  )  const [pure virtual]
 

From BIndexedIterable::CountEntriesLocked().

Implements BIndexedIterable.

Implemented in BSchemaDatabaseNode, BSchemaTableNode::RowNode, BIndexedTableNode::RowNode, and BStructuredNode.

status_t EntryAtLocked const sptr< IndexedIterator > &  it,
size_t  index,
uint32_t  flags,
SValue key,
SValue entry
[virtual]
 

Implement using EntryNameAtLocked() and FetchEntryAtLocked().

Implements BIndexedIterable.

virtual ssize_t EntryIndexOfLocked const SString entry  )  const [pure virtual]
 

Return the index for an entry name in the node.

Return an error code if the lookup failed, usually B_ENTRY_NOT_FOUND.

Implemented in BSchemaDatabaseNode, BSchemaTableNode::RowNode, BIndexedTableNode::RowNode, and BStructuredNode.

virtual SString EntryNameAtLocked size_t  index  )  const [pure virtual]
 

Return the name of an entry at a given index.

This class guarantees it will not call this function with an invalid index.

Implemented in BSchemaDatabaseNode, BSchemaTableNode::RowNode, BIndexedTableNode::RowNode, and BStructuredNode.

status_t FetchEntryAtLocked size_t  index,
uint32_t  flags,
SValue entry
 

Use ValueAtLocked() to retrieve the entry and DatumAtLocked() if INode::REQUEST_DATA is set.

Before retrieving the value, calls AllowDataAtLocked(), to check if it is allowed to return a copy of the data (instead of an IDatum) for this entry.

SValue Inspect const sptr< IBinder > &  caller,
const SValue which,
uint32_t  flags
[virtual]
 

Make both INode and IIterable accessible.

Reimplemented from BnIterable.

Reimplemented in BSchemaDatabaseNode, and BSchemaTableNode::RowNode.

lock_status_t Lock  )  const [virtual]
 

Disambiguate.

Reimplemented from SDatumGeneratorInt.

Reimplemented in BSchemaTableNode::RowNode, and BIndexedTableNode::RowNode.

status_t LookupEntry const SString entry,
uint32_t  flags,
SValue node
[virtual]
 

Implement using EntryIndexOfLocked() and FetchEntryAtLocked().

Implements BGenericNode.

void ReportChangeAtLocked size_t  index,
const sptr< IBinder > &  editor,
uint32_t  changes,
off_t  start = -1,
off_t  length = -1
[virtual]
 

Also push INode::NodeChanged, INode::EntryModified, and IIterator::IteratorChanged events.

Reimplemented from SDatumGeneratorInt.

Reimplemented in BSchemaTableNode::RowNode, and BIndexedTableNode::RowNode.

virtual status_t StoreValueAtLocked size_t  index,
const SValue value
[pure virtual]
 

From SDatumGeneratorInt::StoreValueAtLocked().

Implements SDatumGeneratorInt.

Implemented in BSchemaDatabaseNode, BSchemaTableNode::RowNode, BIndexedTableNode::RowNode, and BStructuredNode.

void Unlock  )  const [virtual]
 

Disambiguate.

Reimplemented from SDatumGeneratorInt.

Reimplemented in BSchemaTableNode::RowNode, and BIndexedTableNode::RowNode.

virtual SValue ValueAtLocked size_t  index  )  const [pure virtual]
 

From SDatumGeneratorInt::ValueAtLocked().

Implements SDatumGeneratorInt.

Implemented in BSchemaDatabaseNode, BSchemaTableNode::RowNode, BIndexedTableNode::RowNode, and BStructuredNode.


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