BStructuredNode Class Reference
[Data Model]

#include <storage/StructuredNode.h>

Inheritance diagram for BStructuredNode:

BIndexedDataNode BMetaDataNode BIndexedIterable SDatumGeneratorInt BGenericNode BGenericIterable SAtom BnNode BnIterable SSQLBuilder INode BBinder IIterable BBinder IInterface IBinder IInterface IBinder SAtom SAtom SAtom SAtom List of all members.

Detailed Description

An INode containing a fixed set of named entries.

BStructuredNode is a convenience class that helps you expose data as a node. You'll want to use this class if you want a node with a fixed set of entries, where you supply the data (unlike BCatalog, which allocates and manages the data for each entry itself).

To use this convenience class, make a subclass of it. Into the constructor, pass an array of strings for the names of the entries and the count of those strings. You must guarantee that those c-strings exist for the lifetime of your object. A common way to do that is to make them static global constants, and to include an SPackageSptr in your subclass. That technique will keep your library loaded (and therefore the strings around) as long as one of your objects exists.

To return data from the class, implement ValueAtLocked(). If your data can be changed, you can optionally implement StoreValueAtLocked(). These APIs operate in terms of indices into your name array.

Via BBIndexedDataNode (and its base classes, BMetaDataNode, BIndexedIterable, and SIndexedDatumGenerator), BStructuredNode takes care of generating IDatums as needed, managing IIterators, and the rest of the functionality needed to participate in the Binder Data Model. You can override various other methods of those classes to further customize the behavior of your node, and use BGenericNode::SetMimeType() to customize the MIME type of your node.


Creation, destruction, locking, etc.

 BStructuredNode (const SContext &context, const char **entries, size_t entryCount, uint32_t mode=IDatum::READ_ONLY)
virtual ~BStructuredNode ()

Public Member Functions

Implement Name Mapping
Using array of names, implement APIs to map from names to data indices.

virtual size_t CountEntriesLocked () const
 Return the number of entries in your array.
virtual ssize_t EntryIndexOfLocked (const SString &entry) const
 Find the index of an entry in your array.
virtual SString EntryNameAtLocked (size_t index) const
 Retrieve the name of an entry at an index in your array.
Get/Set Entry Values
Simplest functions from SIndexedDatumGenerator that must be implement to work with your data. You are free to override other data-related functions on that class for more detailed control.

virtual status_t StoreValueAtLocked (size_t index, const SValue &value)
 Default implementation returns B_UNSUPPORTED.
virtual SValue ValueAtLocked (size_t index) const =0
 Must be implemented as per SIndexedDatumGenerator::ValueAtLocked().

Constructor & Destructor Documentation

BStructuredNode const SContext context,
const char **  entries,
size_t  entryCount,
uint32_t  mode = IDatum::READ_ONLY

~BStructuredNode  )  [protected, virtual]

Member Function Documentation

size_t CountEntriesLocked  )  const [virtual]

Return the number of entries in your array.

Implements BIndexedDataNode.

ssize_t EntryIndexOfLocked const SString entry  )  const [virtual]

Find the index of an entry in your array.

Implements BIndexedDataNode.

SString EntryNameAtLocked size_t  index  )  const [virtual]

Retrieve the name of an entry at an index in your array.

Implements BIndexedDataNode.

status_t StoreValueAtLocked size_t  index,
const SValue value

Default implementation returns B_UNSUPPORTED.

If you override this, be sure to also supply IDatum::READ_WRITE for the mode in your constructor.

Implements BIndexedDataNode.

virtual SValue ValueAtLocked size_t  index  )  const [pure virtual]

Must be implemented as per SIndexedDatumGenerator::ValueAtLocked().

Implements BIndexedDataNode.

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