Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Examples  

gadget::BaseTypeFactory Class Reference

Object used for creating devices. More...

#include <BaseTypeFactory.h>

List of all members.

Public Methods

void registerNetDevice (BaseTypeConstructorBase *constructor)
bool recognizeNetDevice (std::string base_type)
 Queries if the factory knows about the given device. More...

InputloadNetDevice (std::string base_type)
 Loads the specified device. More...


Detailed Description

Object used for creating devices.

Note:
Singleton

Definition at line 84 of file BaseTypeFactory.h.


Member Function Documentation

void gadget::BaseTypeFactory::registerNetDevice BaseTypeConstructorBase   constructor
 

Definition at line 138 of file BaseTypeFactory.cpp.

00139 {
00140    vprASSERT(constructor != NULL);
00141    mConstructors.push_back(constructor);     // Add the constructor to the list
00142    //vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CONFIG_LVL)
00143    //   << "gadget::DeviceFactory: Registered: "
00144    //   << std::setiosflags(std::ios::right) << std::setw(25)
00145    //   << std::setfill(' ') << constructor->getElementType()
00146    //   << std::setiosflags(std::ios::right)
00147       //<< "   :" << (void*)constructor
00148    //   << "  type: " << typeid(*constructor).name() << std::endl
00149    //   << vprDEBUG_FLUSH;
00150 }

bool gadget::BaseTypeFactory::recognizeNetDevice std::string    base_type
 

Queries if the factory knows about the given device.

Precondition:
element != NULL, element is a valid element.
Parameters:
element  The element we are requesting about knowledge to create.
Returns:
true if the factory knows how to create the device; false if not.

Definition at line 154 of file BaseTypeFactory.cpp.

Referenced by loadNetDevice.

00155 {
00156    if(findConstructor(base_type) == -1)
00157       return false;
00158    else
00159       return true;
00160 }

Input * gadget::BaseTypeFactory::loadNetDevice std::string    base_type
 

Loads the specified device.

Precondition:
recognizeDevice(element) == true
Parameters:
element  The specification of the device to load.
Returns:
NULL is returned if the device failed to load. Otherwise, a pointer to the loaded device is returned.

Definition at line 165 of file BaseTypeFactory.cpp.

References gadgetDBG_RIM, and recognizeNetDevice.

00166 {
00167    vprASSERT(recognizeNetDevice(base_type));
00168 
00169    int index = findConstructor(base_type);
00170 
00171    Input* new_dev;
00172    BaseTypeConstructorBase* constructor = mConstructors[index];
00173 
00174    //vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL)
00175    //   << "gadget::BaseType::loadDevice: Loading device: "
00176    //   << element->getID() << "  with: " << typeid(*constructor).name()
00177    //   << std::endl << vprDEBUG_FLUSH;
00178 
00179    new_dev = constructor->createNetDevice(base_type);
00180    if(new_dev!=NULL)
00181    {
00182       vprDEBUG(gadgetDBG_RIM,vprDBG_VERB_LVL) << "[NetDevice Factory] Found the BaseType\n"<< vprDEBUG_FLUSH;
00183    }
00184    return new_dev;
00185 }


The documentation for this class was generated from the following files:
Generated on Sun May 2 14:26:54 2004 for Gadgeteer by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002