JobCPathRegistry Class Reference

#include <JobCPathRegistry.h>

List of all members.

Public Types

typedef std::vector< JobCPath * >
::const_iterator 
PathIterator

Public Member Functions

 JobCPathRegistry ()
 ~JobCPathRegistry ()
JobCModuleLookUpModule (const char *module) const
JobCPathLookUpPath (const char *path) const
JobCPathMakePath (const char *name, MomNavigator *mom, JobCInputModule *inp)
void DeletePath (const char *name)
void Reset ()
PathIterator GetPathBegin () const
PathIterator GetPathEnd () const

Private Attributes

std::vector< JobCPath * > fPathList

Detailed Description

Definition at line 25 of file JobCPathRegistry.h.


Member Typedef Documentation

typedef std::vector<JobCPath*>::const_iterator JobCPathRegistry::PathIterator

Definition at line 28 of file JobCPathRegistry.h.


Constructor & Destructor Documentation

JobCPathRegistry::JobCPathRegistry (  ) 

Definition at line 21 of file JobCPathRegistry.cxx.

References fPathList.

00022 { 
00023   // Initially make room for 10 paths
00024   fPathList.reserve(10);
00025 }

JobCPathRegistry::~JobCPathRegistry (  ) 

Definition at line 29 of file JobCPathRegistry.cxx.

References fPathList.

00030 {
00031 //======================================================================
00032 // Purpose: Delete the paths held by this class
00033 //======================================================================
00034   std::vector<JobCPath*>::iterator itrPath(fPathList.begin());
00035   std::vector<JobCPath*>::iterator itrEnd(fPathList.end());
00036   for (; itrPath != itrEnd; ++itrPath) {
00037     delete (*itrPath);
00038   }
00039 }


Member Function Documentation

void JobCPathRegistry::DeletePath ( const char *  name  ) 

Definition at line 148 of file JobCPathRegistry.cxx.

References fPathList.

Referenced by JobCPathModule::Delete().

00149 {
00150 //======================================================================
00151 // Purpose: Remove a named path from the list of paths
00152 //======================================================================
00153   // Find the path in the table
00154   vector<JobCPath*>::iterator itrPath(fPathList.begin());
00155   vector<JobCPath*>::iterator itrEnd(fPathList.end());
00156   for (; itrPath != itrEnd; ++itrPath) {
00157     if (strcmp(path,(*itrPath)->GetName())==0) {
00158       delete (*itrPath);        // Delete the path pointed to
00159       (*itrPath) = 0;           // Set the path pointer to zero
00160       fPathList.erase(itrPath); // Remove the element from the vector
00161     }
00162   }
00163 }

PathIterator JobCPathRegistry::GetPathBegin (  )  const [inline]

Definition at line 43 of file JobCPathRegistry.h.

References fPathList.

Referenced by Jint::Jint(), and JobCPathModule::Report().

00043 { return fPathList.begin(); }

PathIterator JobCPathRegistry::GetPathEnd (  )  const [inline]

Definition at line 44 of file JobCPathRegistry.h.

References fPathList.

Referenced by Jint::Jint(), and JobCPathModule::Report().

00044 { return fPathList.end(); }

JobCModule * JobCPathRegistry::LookUpModule ( const char *  module  )  const

Definition at line 43 of file JobCPathRegistry.cxx.

References fPathList, Msg::kVerbose, Msg::kWarning, and MSG.

Referenced by JobController::HandleCommand().

00044 {
00045 //======================================================================
00046 // Purpose: Look up a named module in all the existing paths
00047 //
00048 // Input:   mod - The name of the module to look up
00049 //
00050 // Returns: Pointer to the specified job module or 0 if a module with
00051 //          this name cannot be found or there are two modules that 
00052 //          match this name.
00053 //======================================================================
00054 
00055   // Require exactly one match to module name
00056   int nmatch = 0;                      // Number of matches found
00057   JobCModule* jmtry;                   // a path that matches
00058   JobCModule* jm;                      // last match in list
00059   
00060   // Loop over paths looking for modules in them
00061   jmtry = 0;
00062   jm    = 0;
00063   vector<JobCPath*>::const_iterator itrPath(fPathList.begin());
00064   vector<JobCPath*>::const_iterator itrEnd(fPathList.end());
00065   for (; itrPath != itrEnd; ++itrPath) {
00066     jmtry = (*itrPath)->GetModule(module);
00067     if (jmtry!=0) {
00068       jm = jmtry;
00069       MSG("JobC",Msg::kVerbose) << 
00070         "Found " << module << " in path " << (*itrPath)->GetName() << "\n";
00071       ++nmatch;
00072     }
00073   }
00074   
00075   // Check return conditions -- search is sucessful if exactly one
00076   // module was found
00077   // Unique match
00078   if (nmatch == 1) {
00079     // Success - return the last (and only) match in the path
00080     return jm;
00081   }
00082   else if (nmatch > 1) {
00083     // Too many matches
00084     MSG("JobC",Msg::kWarning) << 
00085       "Module specification not unique!\n" <<
00086       " '" << module << "' matches " << nmatch << " possible modules.\n" <<
00087       " Please specify the path name for the module you want, eg:\n" <<
00088       " /[path_name]/[module_name]" << endl;
00089     return 0;
00090   }
00091 
00092   // Module not found -- fall through to here
00093   return 0;
00094 }

JobCPath * JobCPathRegistry::LookUpPath ( const char *  path  )  const

Definition at line 98 of file JobCPathRegistry.cxx.

References fPathList.

Referenced by JobCPathModule::Add(), JobCPathModule::Attach(), JobController::HandleCommand(), MakePath(), and JobCPathModule::operator()().

00099 {
00100 //======================================================================
00101 // Purpose: Loop over existing paths looking for one called "path"
00102 //
00103 // Returns: Pointer to the path if found
00104 //          0 - no matching path found
00105 //======================================================================
00106   // Creation of duplicate path names is not allowed by MakePath, so
00107   // don't bother checking here.
00108   std::vector<JobCPath*>::const_iterator itrPath(fPathList.begin());
00109   std::vector<JobCPath*>::const_iterator itrEnd(fPathList.end());
00110   for (; itrPath != itrEnd; ++itrPath) {
00111     if (strcmp(path,(*itrPath)->GetName())==0) {
00112       return (*itrPath);
00113     }
00114   }
00115   return 0;
00116 }

JobCPath * JobCPathRegistry::MakePath ( const char *  name,
MomNavigator mom,
JobCInputModule inp 
)

Definition at line 120 of file JobCPathRegistry.cxx.

References fPathList, Msg::kWarning, LookUpPath(), and MSG.

Referenced by JobController::BuildSystemPath(), and JobCPathModule::Create().

00123 {
00124 //======================================================================
00125 // Purpose: Create a named path
00126 //======================================================================
00127   // Don't allow duplicate path names
00128   JobCPath* path(this->LookUpPath(name));
00129   if (path != 0) {
00130     MSG("JobC",Msg::kWarning) << 
00131       " Path '" << name << "' already exists!\n";
00132     return 0;
00133   }
00134 
00135   // Create the path and add it to the list ** Remember this module
00136   // owns the paths and has the responsibility to delete them! **
00137   path = new JobCPath(name,mom,inp);
00138   assert(path);
00139   fPathList.push_back(path);
00140 #ifdef SITE_HAS_SIGC
00141   this->NewPath(path);
00142 #endif
00143   return path;
00144 }

void JobCPathRegistry::Reset (  ) 

Definition at line 167 of file JobCPathRegistry.cxx.

References fPathList.

Referenced by JobCPathModule::Reset().

00168 {
00169 //======================================================================
00170 // Delete all active paths
00171 //======================================================================
00172   std::vector<JobCPath*>::iterator itrPath(fPathList.begin());
00173   std::vector<JobCPath*>::iterator itrEnd(fPathList.end());
00174   for (; itrPath != itrEnd; ++itrPath) {
00175     delete (*itrPath); // Delete the path pointed to
00176     (*itrPath) = 0;    // Set the path pointer to zero
00177   }
00178   fPathList.erase(fPathList.begin(),itrEnd);
00179 }


Member Data Documentation

std::vector<JobCPath*> JobCPathRegistry::fPathList [private]

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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1