Itzam/C++

Main Index

Created by Scott Robert Ladd at Coyote Gulch Productions.


itzam::numeric_key< base_t > Class Template Reference

A numeric key type. More...

#include <itzam_common.h>

Inheritance diagram for itzam::numeric_key< base_t >:

itzam::atomic_record< base_t > List of all members.

Public Member Functions

Static Public Member Functions


Detailed Description

template<typename base_t>
class itzam::numeric_key< base_t >

A refinement of the atomic_record type, to implement numerical keys. Key classes must implement the record signature, plus an additional static method:
            static int compare_keys(const void * key1, const void * key2)
        
The compare_keys function operates similar to the C strcmp function, returning < 0 is key1 comes before key2, 0 if the keys are equal, and > 0 when key1 sequences after key2. In the case of a numeric key, the compare function can be implemented simply through subtraction.
Parameters:
base_t A numeric type, likely an integer


Constructor & Destructor Documentation

template<typename base_t>
itzam::numeric_key< base_t >::numeric_key const base_t &  value = 0  )  [inline]
 

Creates a new object with the default underlying value for data_t.

template<typename base_t>
itzam::numeric_key< base_t >::numeric_key const serial_data source  )  [inline]
 

Creates a new object from the raw data addressed by source. This implementation uses a simple static cast and assignment; classes that require more complex initialization will need to define a specialization of database_data.

Parameters:
source Serialized data that will be converted to an object

template<typename base_t>
itzam::numeric_key< base_t >::numeric_key const numeric_key< base_t > &  source  )  [inline]
 

Creates a new object that duplicates source. This implementation assumes that data_t has a simple copy constructor.

Parameters:
source An object to be copied

template<typename base_t>
virtual itzam::numeric_key< base_t >::~numeric_key  )  [inline, virtual]
 

This virtual destructor exists so that derived classes can handle any resource releases they may require, if they are destroyed through a pointer to this base class.


Member Function Documentation

template<typename base_t>
static int itzam::numeric_key< base_t >::compare_keys const void *  key1,
const void *  key2
[inline, static]
 

All key types must define a static member with this signature, to compare raw key objects. For numeric keys, appropriate comparisons can be found via subtraction.

Parameters:
key1 A raw key value
key2 A raw key value
Returns:
If key1 < key2, returns a value < 0; if key1 > key2, returns a value > 0; if keys are equal, returns 0

template<typename base_t>
numeric_key& itzam::numeric_key< base_t >::operator= const serial_data source  )  [inline]
 

Assigned the value of a data_t object to an existing database_data(data_t>. This implementation assumes that data_t supports simple assignment.

Parameters:
source An object to be copied
Returns:
A reference to the target object

Reimplemented from itzam::atomic_record< base_t >.

template<typename base_t>
numeric_key& itzam::numeric_key< base_t >::operator= const base_t &  source  )  [inline]
 

Assigned the value of a data_t object to an existing database_data(data_t>. This implementation assumes that data_t supports simple assignment.

Parameters:
source An object to be copied
Returns:
A reference to the target object

Reimplemented from itzam::atomic_record< base_t >.

template<typename base_t>
numeric_key& itzam::numeric_key< base_t >::operator= const numeric_key< base_t > &  source  )  [inline]
 

Assigned the value of one existing object to another. This implementation assumes that data_t supports simple assignment.

Parameters:
source An object to be copied
Returns:
A reference to the target object


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

© 1996-2005 Scott Robert Ladd. All rights reserved.
HTML documentation generated by Dimitri van Heesch's excellent Doxygen tool.