SDatumGeneratorInt Class Reference
[Data Model]

#include <storage/DatumGeneratorInt.h>

Inheritance diagram for SDatumGeneratorInt:

SAtom BCatalog BIndexedDataNode BPackageManager BIndexedTableNode::RowNode BSchemaDatabaseNode BSchemaTableNode::RowNode BStructuredNode List of all members.

Detailed Description

Utility class for dynamically generating datums associated with integer keys.

This class provides standard tools for generating IDatum objects on-demand that are bound to an integer-based key. It is used when you have data in an indexed vector or structure which is normally stored in its raw form, and need to generate datum objects for its individual pieces of data for integration with the general data model.

Note that because the cached datums generated by this class do not own their data, when an item is removed from the SDatumGeneratorInt a cached datum will loose its associated data. In this case the datum silently becomes B_UNDEFINED_VALUE and modifications to it are no longer allowed.

Todo:
May want to revisit deletion, the value that gets set and if any events get pushed when it happens.


Index Management

Manage the mapping of indices to datums.

sptr< IDatumDatumAtLocked (size_t index)
 Retrieve a datum of a given index.
void UpdateDatumIndicesLocked (size_t index, ssize_t delta)
 Adjust all active datums due to items being added/removed from the generator.

Stream Virtuals

These are like the corresponding virtuals on BStreamDatum.

virtual void FinishReadingAtLocked (size_t index, const void *data) const
 The default implementation does nothing.
virtual void FinishWritingAtLocked (size_t index, void *data)
 The default implementation uses StoreValueAtLocked() to write the data.
virtual const void * StartReadingAtLocked (size_t index, off_t position, ssize_t *inoutSize, uint32_t flags) const
 The default implementation return uses ValueAtLocked() to retrieve the data.
virtual void * StartWritingAtLocked (size_t index, off_t position, ssize_t *inoutSize, uint32_t flags)
 The default implementation uses ValueAtLocked() to create a temporary buffer.

Bookkeeping

Creation, destruction, locking, etc.

virtual lock_status_t Lock () const
 Lock the datum's state.
 SDatumGeneratorInt (const SContext &context, uint32_t mode=IDatum::READ_WRITE)
 Lock the datum's state.
 SDatumGeneratorInt (uint32_t mode=IDatum::READ_WRITE)
 Lock the datum's state.
virtual void Unlock () const
 Unlock the datum's state.
virtual ~SDatumGeneratorInt ()
 Lock the datum's state.

Datum Generation

virtual sptr< IndexedDatumNewDatumLocked (size_t index, uint32_t mode)
 Called when a new datum object needs to be created.

Value-based Structure Access

These are like the corresponding virtuals on BStreamDatum.

virtual void ReportChangeAtLocked (size_t index, const sptr< IBinder > &editor, uint32_t changes, off_t start=-1, off_t length=-1)
 Similar to BStreamDatum::ReportChangeLocked(), using same change flags.
void SetValueAtLocked (size_t index, const SValue &value)
 Convenience function for changing a value.
virtual off_t SizeAtLocked (size_t index) const
 The default implementation returns ValueAtLocked().Length().
virtual status_t StoreSizeAtLocked (size_t index, off_t size)
 The default implementation uses ValueAtLocked() and StoreValueAtLocked() to change the size.
virtual status_t StoreValueAtLocked (size_t index, const SValue &value)=0
 Must be implemented by subclasses change the current value at an index.
virtual status_t StoreValueTypeAtLocked (size_t index, uint32_t type)
 The default implementation uses ValueAtLocked() and StoreValueAtLocked() to change the type.
virtual SValue ValueAtLocked (size_t index) const =0
 Must be implemented by subclasses to return the current value at an index.
virtual uint32_t ValueTypeAtLocked (size_t index) const
 The default implementation returns ValueAtLocked().Type().

Friends

class IndexedDatum

Classes

class  IndexedDatum
 Datum object generated for an item in SDatumGeneratorInt. More...


Constructor & Destructor Documentation

SDatumGeneratorInt uint32_t  mode = IDatum::READ_WRITE  ) 
 

Lock the datum's state.

To keep itself consistent, this class provides a public lock that is used when doing read/write operations on the class state as well as the actual data. The default implemention of this method acquires an internal lock. You can override it to cause all internal implementation to acquire some other lock. Be sure to also override Unlock() if doing so.

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

Lock the datum's state.

To keep itself consistent, this class provides a public lock that is used when doing read/write operations on the class state as well as the actual data. The default implemention of this method acquires an internal lock. You can override it to cause all internal implementation to acquire some other lock. Be sure to also override Unlock() if doing so.

~SDatumGeneratorInt  )  [protected, virtual]
 

Lock the datum's state.

To keep itself consistent, this class provides a public lock that is used when doing read/write operations on the class state as well as the actual data. The default implemention of this method acquires an internal lock. You can override it to cause all internal implementation to acquire some other lock. Be sure to also override Unlock() if doing so.


Member Function Documentation

sptr< IDatum > DatumAtLocked size_t  index  ) 
 

Retrieve a datum of a given index.

Returns an existing datum if one is currently active for the index. Otherwise, calls NewDatumLocked() to create a new datum and associates it with this index.

void FinishReadingAtLocked size_t  index,
const void *  data
const [virtual]
 

The default implementation does nothing.

Reimplemented in BIndexedTableNode::RowNode.

void FinishWritingAtLocked size_t  index,
void *  data
[virtual]
 

The default implementation uses StoreValueAtLocked() to write the data.

Reimplemented in BIndexedTableNode::RowNode.

lock_status_t Lock  )  const [virtual]
 

Lock the datum's state.

To keep itself consistent, this class provides a public lock that is used when doing read/write operations on the class state as well as the actual data. The default implemention of this method acquires an internal lock. You can override it to cause all internal implementation to acquire some other lock. Be sure to also override Unlock() if doing so.

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

sptr< SDatumGeneratorInt::IndexedDatum > NewDatumLocked size_t  index,
uint32_t  mode
[virtual]
 

Called when a new datum object needs to be created.

The default implementation instantiates and returns a new IndexedDatum object.

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

Similar to BStreamDatum::ReportChangeLocked(), using same change flags.

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

void SetValueAtLocked size_t  index,
const SValue value
 

Convenience function for changing a value.

The implementation takes care of calling ReportChangeAtLocked() for you if the value has changed. This is semantically the same as BStreamDatum::SetValue().

off_t SizeAtLocked size_t  index  )  const [virtual]
 

The default implementation returns ValueAtLocked().Length().

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

const void * StartReadingAtLocked size_t  index,
off_t  position,
ssize_t *  inoutSize,
uint32_t  flags
const [virtual]
 

The default implementation return uses ValueAtLocked() to retrieve the data.

Reimplemented in BIndexedTableNode::RowNode.

void * StartWritingAtLocked size_t  index,
off_t  position,
ssize_t *  inoutSize,
uint32_t  flags
[virtual]
 

The default implementation uses ValueAtLocked() to create a temporary buffer.

Reimplemented in BIndexedTableNode::RowNode.

status_t StoreSizeAtLocked size_t  index,
off_t  size
[virtual]
 

The default implementation uses ValueAtLocked() and StoreValueAtLocked() to change the size.

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

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

Must be implemented by subclasses change the current value at an index.

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

status_t StoreValueTypeAtLocked size_t  index,
uint32_t  type
[virtual]
 

The default implementation uses ValueAtLocked() and StoreValueAtLocked() to change the type.

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

void Unlock  )  const [virtual]
 

Unlock the datum's state.

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

void UpdateDatumIndicesLocked size_t  index,
ssize_t  delta
 

Adjust all active datums due to items being added/removed from the generator.

Your subclass must call this when it changes its set of datum items.

virtual SValue ValueAtLocked size_t  index  )  const [pure virtual]
 

Must be implemented by subclasses to return the current value at an index.

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

uint32_t ValueTypeAtLocked size_t  index  )  const [virtual]
 

The default implementation returns ValueAtLocked().Type().

Reimplemented in BIndexedTableNode::RowNode.


Friends And Related Function Documentation

friend class IndexedDatum [friend]
 


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