gadget::BaseTypeFactory Class Reference

Object used for creating devices. More...

#include <gadget/Type/BaseTypeFactory.h>

List of all members.

Public Member Functions

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


Detailed Description

Object used for creating devices.

Definition at line 91 of file BaseTypeFactory.h.


Member Function Documentation

void gadget::BaseTypeFactory::registerNetDevice ( BaseTypeConstructorBase constructor  ) 

Definition at line 156 of file BaseTypeFactory.cpp.

00157 {
00158    vprASSERT(constructor != NULL);
00159    mConstructors.push_back(constructor);     // Add the constructor to the list
00160 }

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

Queries if the factory knows about the given device.

Precondition:
base_type is a valid configuration element type.
Parameters:
base_type The base type of the config element 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 164 of file BaseTypeFactory.cpp.

Referenced by loadNetDevice().

00165 {
00166    return ! (findConstructor(base_type) == -1);
00167 }

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

Loads the specified device.

Precondition:
recognizeNetDevice(base_type) == true.
Parameters:
base_type The base type of 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.
See also:
recognizeNetDevice

Definition at line 172 of file BaseTypeFactory.cpp.

References gadget::BaseTypeConstructorBase::createNetDevice(), gadgetDBG_RIM(), and recognizeNetDevice().

00173 {
00174    vprASSERT(recognizeNetDevice(base_type));
00175 
00176    int index = findConstructor(base_type);
00177 
00178    Input* new_dev;
00179    BaseTypeConstructorBase* constructor = mConstructors[index];
00180 
00181    new_dev = constructor->createNetDevice(base_type);
00182    if(new_dev!=NULL)
00183    {
00184       vprDEBUG(gadgetDBG_RIM,vprDBG_VERB_LVL)
00185          << "[NetDevice Factory] Found the BaseType\n"<< vprDEBUG_FLUSH;
00186    }
00187    return new_dev;
00188 }


The documentation for this class was generated from the following files:
Generated on Thu Jan 4 10:44:50 2007 for Gadgeteer by  doxygen 1.5.1