#include <support/IDatum.h>
Inheritance diagram for IDatum:
An IDatum represents a single, indivisible piece of data in the Binder Data Model. Clients will usually use the SDatum convenience class instead of making direct calls on an IDatum. Implementations should never directly implement IDatum, instead deriving from BGenericDatum or one of its subclasses.
The IDatum API is designed to enable two approaches to accessing data. The first maps directly to a traditional file, where you perform an "open" operation to retrieve one or more interfaces (of IStorage, IByteInput, IByteOutput, IByteSeekable) that read and/or write a raw stream of bytes. You can also view it as a container for a single piece of data, in which case you retrieve and write it as a single SValue object type.
In general you will always be able to Open() the contents of a datum, but there will be many times when you can't retrieve it directly as an SValue. For example, if the datum is more than 4KB, it will exceed the current IPC data size limit.
The value of a datum should never contain a Binder object. If you want to place a Binder object at a location in the namespace, it can be put there directly without wrapping it in a datum. The role of the datum is really to provide a Binder object for data that otherwise is not itself an object.
The CopyTo() and CopyFrom() methods allow the datum to implement optimized opying paths. The BGenericDatum base class implements both of these by either manually copying the data (reading from the source and writing to the destination) if NO_COPY_REDIRECTION is set, or calling the matching version on the other datum with NO_COPY_REDIRECTION. Subclasses can implement specialized versions of these functions in cases where they can perform copies between datums more efficiently.
Public Types | |
enum | { READ_ONLY = 0x0000, WRITE_ONLY = 0x0001, READ_WRITE = 0x0002, READ_WRITE_MASK = 0x0003, ERASE_DATUM = 0x0200, OPEN_AT_END = 0x0400 } |
enum | { NO_COPY_REDIRECTION = 0x0001 } |
Public Member Functions | |
virtual status_t | CopyFrom (const sptr< IDatum > &src, uint32_t flags=0)=0 |
Read src in to this datum. | |
virtual status_t | CopyTo (const sptr< IDatum > &dest, uint32_t flags=0)=0 |
Write this datum in to dest. | |
status_t | LinkDatum (const sptr< IBinder > &to, const SValue &mappings, uint32_t flags=0) |
virtual sptr< IBinder > | Open (uint32_t mode, const sptr< IBinder > &editor=NULL, uint32_t newType=0)=0 |
Access data as stream/storage. | |
virtual void | SetSize (off_t value)=0 |
Number of bytes in datum. | |
virtual void | SetValue (const SValue &value)=0 |
Access datum as an SValue. | |
virtual void | SetValueType (uint32_t value)=0 |
Current type code of this datum. Default is B_RAW_TYPE. | |
virtual off_t | Size () const =0 |
Number of bytes in datum. | |
status_t | UnlinkDatum (const sptr< IBinder > &to, const SValue &mappings, uint32_t flags=0) |
virtual SValue | Value () const =0 |
Access datum as an SValue. | |
virtual uint32_t | ValueType () const =0 |
Current type code of this datum. Default is B_RAW_TYPE. | |
Protected Member Functions | |
IDatum () | |
virtual | ~IDatum () |
|
|
|
|
|
|
|
|
|
Read src in to this datum. Upon a succeessful return, this datum will hold the same data as src. The implementation may accomplish this by calling CopyTo() on src, unless the NO_COPY_REDIRECTION flag is set. Implemented in BGenericDatum. |
|
Write this datum in to dest. Upon a succeessful return, dest will contain the same data as the source datum. The implementation may accomplish this by calling CopyFrom() on dest, unless the NO_COPY_REDIRECTION flag is set. Implemented in BGenericDatum. |
|
|
|
Access data as stream/storage.
Implemented in BStreamDatum, and SDatumLord::Datum. |
|
Number of bytes in datum.
Implemented in BStreamDatum, and SDatumLord::Datum. |
|
Access datum as an SValue. You can link to this for notifications when the datum changes. If the datum can not be represented as a value, the value here is "undefined" OR an error value, and it is not pushed when the datum changes. To ensure you always get notified when it changes, you should use the DatumChanged event. Implemented in BStreamDatum, and SDatumLord::Datum. |
|
Current type code of this datum. Default is B_RAW_TYPE.
Implemented in BStreamDatum, and SDatumLord::Datum. |
|
Number of bytes in datum.
Implemented in BStreamDatum, and SDatumLord::Datum. |
|
|
|
Access datum as an SValue. You can link to this for notifications when the datum changes. If the datum can not be represented as a value, the value here is "undefined" OR an error value, and it is not pushed when the datum changes. To ensure you always get notified when it changes, you should use the DatumChanged event. Implemented in BStreamDatum, and SDatumLord::Datum. |
|
Current type code of this datum. Default is B_RAW_TYPE.
Implemented in BStreamDatum, and SDatumLord::Datum. |