Rudiments
Public Member Functions | List of all members
wastebasket Class Reference

Inherits object.

Public Member Functions

 wastebasket ()
 
virtual ~wastebasket ()
 
void attach (char *value)
 
void attach (wchar_t *value)
 
void attach (byte_t *value)
 
void attach (int16_t *value)
 
void attach (int32_t *value)
 
void attach (int64_t *value)
 
void attach (uint16_t *value)
 
void attach (uint32_t *value)
 
void attach (uint64_t *value)
 
void attach (float *value)
 
void attach (double *value)
 
void attach (long double *value)
 
void attach (object *o)
 
void attach (object **o)
 
void empty ()
 
- Public Member Functions inherited from object
virtual ~object ()
 

Detailed Description

The wastebasket class provides an garbage collection object. Arbitrary arrays of primitives, objects, and arrays of objects can be attached to it and deleted at a later date.

Useful for holding on to dependencies of an object until the object no longer needs them.

For example:

int main() { wastebasket w; getInformation(&w).display(); w.empty(); }

information *getInformation(wastebasket *w) {

    // Assume that information, dbconnection and dbcursor all
// inherit from the rudiments object class.
// 
// Assume also, that the dbresultset class inherits from the
// information class and implements its display() method.

dbconnection        *con=createDatabaseConnection();
dbcursor    *cur=con->createDatabaseCursor();
dbresultset *rs=cur->runQuery("...some query...");
w->attach(rs);
w->attach(cur);
w->attach(con);
return rs;

}

In this example, getInformation() creates a connection to a database, creates a cursor for running a query, and runs a query using that cursor to create a result set. The result set is then passed back to main() which displays it.

In this code, the rs object requires that the cur and con objects still exist in order to execute its display() method.

While all three objects could be passed back to main(), or created in main() and passed down, using a wastebasket allows getInformation() to completely hide its implementation details from main().

This is especially useful in MVC applications.

Constructor & Destructor Documentation

◆ wastebasket()

wastebasket::wastebasket ( )

Creates an instance of the wastebasket class.

◆ ~wastebasket()

virtual wastebasket::~wastebasket ( )
virtual

Deletes this instance of the wastebasket class.

Member Function Documentation

◆ attach() [1/14]

void wastebasket::attach ( byte_t *  value)

Attaches "value" such that it will be array-deleted when empty() is called.

◆ attach() [2/14]

void wastebasket::attach ( char *  value)

Attaches "value" such that it will be array-deleted when empty() is called.

◆ attach() [3/14]

void wastebasket::attach ( double *  value)

Attaches "value" such that it will be array-deleted when empty() is called.

◆ attach() [4/14]

void wastebasket::attach ( float *  value)

Attaches "value" such that it will be array-deleted when empty() is called.

◆ attach() [5/14]

void wastebasket::attach ( int16_t *  value)

Attaches "value" such that it will be array-deleted when empty() is called.

◆ attach() [6/14]

void wastebasket::attach ( int32_t *  value)

Attaches "value" such that it will be array-deleted when empty() is called.

◆ attach() [7/14]

void wastebasket::attach ( int64_t *  value)

Attaches "value" such that it will be array-deleted when empty() is called.

◆ attach() [8/14]

void wastebasket::attach ( long double *  value)

Attaches "value" such that it will be array-deleted when empty() is called.

◆ attach() [9/14]

void wastebasket::attach ( object **  o)

Attaches "value" such that it will be array-deleted when empty() is called.

◆ attach() [10/14]

void wastebasket::attach ( object o)

Attaches "value" such that it will be deleted when empty() is called.

◆ attach() [11/14]

void wastebasket::attach ( uint16_t *  value)

Attaches "value" such that it will be array-deleted when empty() is called.

◆ attach() [12/14]

void wastebasket::attach ( uint32_t *  value)

Attaches "value" such that it will be array-deleted when empty() is called.

◆ attach() [13/14]

void wastebasket::attach ( uint64_t *  value)

Attaches "value" such that it will be array-deleted when empty() is called.

◆ attach() [14/14]

void wastebasket::attach ( wchar_t *  value)

Attaches "value" such that it will be array-deleted when empty() is called.

◆ empty()

void wastebasket::empty ( )

Deletes or array-deletes, as appropriate, all values previously attached using the attach() methods.