Main Page

Functions
avrclass.c File Reference

Go to the source code of this file.

## Functions
AvrClass * | class_new (void)
void | class_construct (AvrClass *klass)
void | class_destroy (void *klass)
void | class_overload_destroy (AvrClass *klass, AvrClassFP_Destroy destroy)
void | class_ref (AvrClass *klass)
void | class_unref (AvrClass *klass)

## Detailed Description

Methods to provide user interfaces to the AvrClass structure.

This module provides the basis for simulavr's object mechanism. For a detailed discussion on using simulavr's class mechanism, see the simulavr users manual. FIXME: [TRoth 2002/03/19] move the discussion here.

Definition in file avrclass.c.

## Function Documentation

## § class_new()

AvrClass* class_new | ( | void |  | ) |

This function should never be used.

The only potential use for it as a template for derived classes. Do Not Use This Function!

Definition at line 46 of file avrclass.c.

References avr_new, and class_construct().

## § class_construct()

void class_construct | ( | AvrClass * | klass | ) |

Initializes the AvrClass data structure.

A derived class should call this function from their own <klass>_construct() function. All classes should have their constructor function call their parent's constructor function.

Definition at line 61 of file avrclass.c.

References avr_error, class_destroy(), and class_overload_destroy().

Referenced by class_new(), mem_construct(), stack_construct(), and vdev_construct().

## § class_destroy()

void class_destroy | ( | void * | klass | ) |

Releases resources allocated by class's <klass>_new() function.

This function should never be called except as the last statement of a directly derived class's destroy method. All classes should have their destroy method call their parent's destroy method.

Definition at line 78 of file avrclass.c.

References avr_free().

Referenced by avr_core_destroy(), class_construct(), mem_destroy(), stack_destroy(), and vdev_destroy().

## § class_overload_destroy()

void class_overload_destroy | ( | AvrClass * | klass,
|  | AvrClassFP_Destroy | destroy
| ) |  |

Overload the default destroy method.

Derived classes will call this to replace class_destroy() with their own destroy method.

Definition at line 92 of file avrclass.c.

References avr_error.

Referenced by class_construct(), flash_new(), hwstack_new(), mem_new(), memstack_new(), stack_new(), and vdev_new().

## § class_ref()

void class_ref | ( | AvrClass * | klass | ) |

Increments the reference count for the klass object.

The programmer must call this whenever a reference to an object is stored in more than one place.

Definition at line 106 of file avrclass.c.

References avr_error.

Referenced by mem_attach().

## § class_unref()

void class_unref | ( | AvrClass * | klass | ) |

Decrements the reference count for the klass object.

When the reference count reaches zero, the class's destroy method is called on the object.

Definition at line 120 of file avrclass.c.

References avr_error.

Referenced by avr_core_destroy(), dlist_delete(), dlist_delete_all(), mem_destroy(), and memstack_destroy().

Automatically generated by Doxygen 1.8.12 on Sun Apr 2 2017.