Chunk pointer template (package chunkptr)

14sep98 2220
Code version 0.11


Links to code

The description below includes links to the code contained in this package. This version of the code may not be the most recent.

Description

Package chunkptr contains templates describing a pointer to an object inside a chunk.

The physical components include:

There are also some headers used for testing:

These provide an example defining an index, data type and chunk.

This package depends on the following external packages:

The classes defined in the above components are described below. Each class is defined in a component of the same name unless otherwise indicated. The descriptions are brief. See the header files for details.


Event reference

EventPtr is the type by which events are referenced. Presently it is a pointer class which does not provide management but is notified when the event is deleted.

Pointer data

Template ChunkObjectIndex<C,OID> hold the data required to build a pointer to an object inside a chunk. Here C is the chunk type and OID is the type of the index used to identify the object within the chunk. The data includes an event pointer, the chunk ID and the local chunk object index. Classes which do not have physical dependency on the object or chunk types may safely construct these objects. Thes can be used to construct or assign the pointers described in the next section.

Pointers

Template ChunkObjectPtr<T,C,OID> implements the AbsPtr<T> interface for a pointer into a chunk (see package ptr). Here T is the object type, C is the chunk type and OID is the type of the index specifying the object. These pointers are constructed with name-only dependence on the three arguments but the AbsPtr operations require coupling to the chunk type and, of course, member selection requires coupling to the object type.

Pointers

The chunk access is carried out by the template function get_chunk_object<T,C,OID>. There is no generic implementation. Chunks designers are expected to create a fully-typed specialization which extracts the object from the chunk. An example of this specialization may be found in TestChunk.


Example

Here we present a brief example. There is a class BDatum which wishes to reference an object of type ADatum in a chunk of type AChunk indexed by type AIndex. This is accomplished by having BDatum hold an object of type ChunkObjectIndex<AChunk,AIndex>. It is returned by method get_bdatum(). An external user may copy or assign this into an object of type ChunkObjectPtr<ADatum,AChunk,AIndex> which behaves like const ADatum*.

The figure shows the physical coupling between these classes.

  // Some function returns the BDatum
  BDatum& b = fetch_bdatm();

  // Fetch "pointer" to ADatum
  // (bdat returns index which is automatically converted to ptr)
  ChunkObjectPtr<ADatum,AChunk,AIndex> pa = bdat.get_adatum();

  // Access a
  double pt = pa->get_pt();


Release notes


Questions or comments to adams@physics.rice.edu.