torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
torc::architecture::DDBStreamHelper Class Reference

Device database stream helper class. More...

#include <DDBStreamHelper.hpp>

Static Public Member Functions

static const class DDBgetDDBPtr (std::ostream &os)
 Return the device database pointer associated with this stream. More...
 
static void dissociate (const class DDB &ddb)
 Dissociate the given device database from any stream. More...
 

Protected Types

typedef std::map< std::ostream
*, const class DDB * > 
OStreamToDDBMap
 Map of streams to database pointers. More...
 

Static Protected Attributes

static OStreamToDDBMap sStreamToDatabase
 Map of streams to databases. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const class DDB &ddb)
 Insertion operator to associate the given device database with the given stream. More...
 

Detailed Description

Device database stream helper class.

This helper class allows the caller to associate a device database with an output stream. This allows extremely lightweight classes like Tilewire to decorate their output with additional information, without requiring their own database reference.

Note
The database reference only needs to be inserted one time into the stream.
std::cout << ddb << ...;

Definition at line 35 of file DDBStreamHelper.hpp.

Member Typedef Documentation

typedef std::map<std::ostream*, const class DDB*> torc::architecture::DDBStreamHelper::OStreamToDDBMap
protected

Map of streams to database pointers.

Definition at line 42 of file DDBStreamHelper.hpp.

Member Function Documentation

static void torc::architecture::DDBStreamHelper::dissociate ( const class DDB ddb)
inlinestatic

Dissociate the given device database from any stream.

Definition at line 56 of file DDBStreamHelper.hpp.

56  {
57  const DDB* ddbPtr = &ddb;
58  // iterate through all streams that have an association
59  OStreamToDDBMap::iterator p = sStreamToDatabase.begin();
60  OStreamToDDBMap::iterator e = sStreamToDatabase.end();
61  while(p != e) {
62  // if we find a stream associated with this database, remove the association
63  if(p->second == ddbPtr) sStreamToDatabase.erase(p);
64  p++;
65  }
66  }
static OStreamToDDBMap sStreamToDatabase
Map of streams to databases.

+ Here is the caller graph for this function:

static const class DDB* torc::architecture::DDBStreamHelper::getDDBPtr ( std::ostream &  os)
inlinestatic

Return the device database pointer associated with this stream.

Returns
the device database pointer, or 0 if no database has been associated with the stream.

Definition at line 50 of file DDBStreamHelper.hpp.

50  {
51  OStreamToDDBMap::const_iterator p = sStreamToDatabase.find(&os);
52  if(p == sStreamToDatabase.end()) return 0;
53  return p->second;
54  }
static OStreamToDDBMap sStreamToDatabase
Map of streams to databases.

+ Here is the caller graph for this function:

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const class DDB ddb 
)
friend

Insertion operator to associate the given device database with the given stream.

This operator does not generate any stream output, but instead associates the given device database with the stream. This allows lightweight objects such as tilewires to decorate their output with database information, without including a database reference.

Field Documentation

DDBStreamHelper::OStreamToDDBMap torc::architecture::DDBStreamHelper::sStreamToDatabase
staticprotected

Map of streams to databases.

Definition at line 45 of file DDBStreamHelper.hpp.


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