jccl::DepChecker Class Reference

Base class for dependency checkers. More...

#include <jccl/RTRC/DepChecker.h>

List of all members.

Public Member Functions

 DepChecker ()
 Constructor.
virtual ~DepChecker ()
 Destructor.
virtual std::string getCheckerName ()
 Return a string name for the checker.
virtual bool canHandle (ConfigElementPtr element)
 Checks if this DepChecker knows how to handle element.
virtual bool depSatisfied (ConfigElementPtr element)
 Checks if element's dependencies are satisfied.
virtual void debugOutDependencies (ConfigElementPtr element, int dbgLevel=vprDBG_WARNING_LVL)
 Write element's dependencies to vprDEBUG.


Detailed Description

Base class for dependency checkers.

A dependency checker is responsible for figuring out if the system has all the required dependencies filled for a given jccl::ConfigElement.

This class also implements a default behavior for dependency checkers, which just looks at any jccl::ConfigElement pointer properties in the given element and returns true if all the elements named by those properties exist in the ConfigManager's current configuration.

Configuration information with special dependency requirements should specialize this class and register an instance with the Dependency Manager.

Note:
The DepChecker must be registered BEFORE a element of the given type is checked for dependencies.

Definition at line 62 of file DepChecker.h.


Constructor & Destructor Documentation

jccl::DepChecker::DepChecker (  ) 

Constructor.

Definition at line 42 of file DepChecker.cpp.

00043 {;}

virtual jccl::DepChecker::~DepChecker (  )  [inline, virtual]

Destructor.

Definition at line 69 of file DepChecker.h.

00070    {;}


Member Function Documentation

std::string jccl::DepChecker::getCheckerName (  )  [virtual]

Return a string name for the checker.

This is used to output messages in checker listings.

Definition at line 45 of file DepChecker.cpp.

Referenced by jccl::DependencyManager::registerChecker().

00046 {
00047    return std::string("Default Checker");
00048 }

bool jccl::DepChecker::canHandle ( ConfigElementPtr  element  )  [virtual]

Checks if this DepChecker knows how to handle element.

Returns:
true if we understand the element. The default behavior returns true (the default checker can check anything).

Definition at line 50 of file DepChecker.cpp.

00051 {
00052    boost::ignore_unused_variable_warning(element);
00053    return true;
00054 }

bool jccl::DepChecker::depSatisfied ( ConfigElementPtr  element  )  [virtual]

Checks if element's dependencies are satisfied.

Returns:
true iff element's dependencies are satisfied.

Definition at line 56 of file DepChecker.cpp.

References jccl::ConfigManager::isElementInActiveList().

00057 {
00058    bool pass = true;
00059 
00060    ConfigManager* cfg_mgr = ConfigManager::instance();
00061 
00062    // Get the list of dependencies
00063    std::vector<std::string> dependencies =
00064       element->getElementPtrDependencies();
00065 
00066    // Check to see if they are loaded already
00067    for (unsigned int i = 0 ; i < dependencies.size() ; i++)
00068    {
00069       if (!cfg_mgr->isElementInActiveList(dependencies[i]))
00070       {
00071          pass = false;
00072       }
00073    }
00074    return pass;
00075 }

void jccl::DepChecker::debugOutDependencies ( ConfigElementPtr  element,
int  dbgLevel = vprDBG_WARNING_LVL 
) [virtual]

Write element's dependencies to vprDEBUG.

Parameters:
element The element whose dependencies will be printed.
dbgLevel Output priority level for vprDEBUG.

Definition at line 78 of file DepChecker.cpp.

References jccl::ConfigManager::isElementInActiveList().

00079 {
00080    vprDEBUG_NEXT_BEGIN(vprDBG_ALL,dbg_lvl)
00081       << "---- Dependencies for " << element->getName()
00082       << " (type: " << element->getID() << ") ----\n" << vprDEBUG_FLUSH;
00083 
00084    ConfigManager* cfg_mgr = ConfigManager::instance();
00085 
00086    // Get the list of dependencies
00087    std::vector<std::string> dependencies = element->getElementPtrDependencies();
00088 
00089    // Check to see if they are loaded already
00090    for (unsigned int i = 0 ; i < dependencies.size() ; i++)
00091    {
00092       vprDEBUG_NEXT(vprDBG_ALL,dbg_lvl) << i << ": "
00093           << dependencies[i].c_str()
00094           << " ==> " << vprDEBUG_FLUSH;
00095       if (!cfg_mgr->isElementInActiveList(dependencies[i]))
00096       {
00097          vprDEBUG_CONT(vprDBG_ALL,dbg_lvl) << "not available.\n" << vprDEBUG_FLUSH;
00098       }
00099       else
00100       {
00101          vprDEBUG_CONT(vprDBG_ALL,dbg_lvl) << "passed.\n" << vprDEBUG_FLUSH;
00102       }
00103    }
00104 
00105    vprDEBUG_CONT_END(vprDBG_ALL,dbg_lvl) << std::endl << vprDEBUG_FLUSH;
00106 
00107 }


The documentation for this class was generated from the following files:
Generated on Thu Jan 4 10:49:55 2007 for JCCL: Juggler Configuration and Control Library by  doxygen 1.5.1