root/juggler/tags/1.0.5/Kernel/vjDepChecker.h

Revision 7539, 4.5 kB (checked in by anonymous, 7 years ago)

This commit was manufactured by cvs2svn to create tag
'RELENG_1_0_5_RELEASE'.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /*************** <auto-copyright.pl BEGIN do not edit this line> **************
2  *
3  * VR Juggler is (C) Copyright 1998, 1999, 2000 by Iowa State University
4  *
5  * Original Authors:
6  *   Allen Bierbaum, Christopher Just,
7  *   Patrick Hartling, Kevin Meinert,
8  *   Carolina Cruz-Neira, Albert Baker
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Library General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Library General Public License for more details.
19  *
20  * You should have received a copy of the GNU Library General Public
21  * License along with this library; if not, write to the
22  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23  * Boston, MA 02111-1307, USA.
24  *
25  * -----------------------------------------------------------------
26  * File:          $RCSfile$
27  * Date modified: $Date$
28  * Version:       $Revision$
29  * -----------------------------------------------------------------
30  *
31  *************** <auto-copyright.pl END do not edit this line> ***************/
32
33
34 #ifndef _VJ_DEP_CHECKER_H_
35 #define _VJ_DEP_CHECKER_H_
36 //#pragma once
37
38 #include <vjConfig.h>
39 #include <Input/vjInput/vjInput.h>
40 #include <Config/vjConfigChunk.h>
41 #include <Kernel/vjConfigManager.h>
42
43 //: Base class for dependency checkers
44 //
45 // A dependency checker is responsible for figuring out
46 // if the system has all the required dependencies filled
47 // for a given configChunk
48 //<br>
49 // This class also implements a default behavior for
50 // dependency checkers, that just looks at the chunk
51 // ptrs in the given chunk and returns true if
52 // all chunk ptrs have those corresponding chunks
53 // loaded in the current configuration.
54 // <br>
55 // Configuration information with special
56 // dependency requirements should implement
57 // a specialization of this class and register
58 // it with the dependency checker.
59 // <br>
60 // NOTE: It must be registered BEFORE
61 // a chunk of the given type is checked for dependencies.
62 //!PUBLIC_API
63 class vjDepChecker
64 {
65 public:
66    vjDepChecker()
67    {;}
68
69    //: Return a string name of the checker
70    // Used to output messages in checker listings
71    virtual std::string getCheckerName()
72    { return std::string("Default Checker"); }
73
74    // Can we handle the given chunk type?
75    // Default to true, because the default checker can check anything
76    virtual bool canHandle(vjConfigChunk* chunk)
77    {
78       return true;
79    }
80
81    //: Are the dependencies satisfied?
82    //! RETURNS: true - dependencies are satisfied
83    virtual bool depSatisfied(vjConfigChunk* chunk)
84    {
85       bool pass=true;
86
87       vjConfigManager* cfg_mgr = vjConfigManager::instance();
88
89       // Get the list of dependencies
90       std::vector<std::string> dependencies = chunk->getChunkPtrDependencies();
91
92       // Check to see if they are loaded already
93       for(unsigned int i=0;i<dependencies.size();i++)
94       {
95          if(!cfg_mgr->isChunkInActiveList(dependencies[i]))
96             pass = false;
97       }
98       return pass;
99    }
100
101    // Write out the dependencies to the vjDEBUG macro
102    virtual void debugOutDependencies(vjConfigChunk* chunk,int dbg_lvl=vjDBG_WARNING_LVL)
103    {
104       vjDEBUG_NEXT_BEGIN(vjDBG_ALL,dbg_lvl) << "---- Dependencies for: item: "
105                                             << chunk->getProperty("name")
106                                             << " type: " << ((std::string)chunk->getType()).c_str()
107                                             << "-------\n" << vjDEBUG_FLUSH;
108
109       vjConfigManager* cfg_mgr = vjConfigManager::instance();
110
111       // Get the list of dependencies
112       std::vector<std::string> dependencies = chunk->getChunkPtrDependencies();
113
114       // Check to see if they are loaded already
115       for(unsigned int i=0;i<dependencies.size();i++)
116       {
117          vjDEBUG_NEXT(vjDBG_ALL,dbg_lvl) << i << ": "
118                                          << dependencies[i].c_str()
119                                          << " ==> " << vjDEBUG_FLUSH;
120          if(!cfg_mgr->isChunkInActiveList(dependencies[i]))
121          {
122             vjDEBUG_CONT(vjDBG_ALL,dbg_lvl) << "not available.\n" << vjDEBUG_FLUSH;
123          }
124          else
125          {
126             vjDEBUG_CONT(vjDBG_ALL,dbg_lvl) << "passed.\n" << vjDEBUG_FLUSH;
127          }
128       }
129
130       vjDEBUG_CONT_END(vjDBG_ALL,dbg_lvl) << std::endl << vjDEBUG_FLUSH;
131
132    }
133 };
134
135 #endif
136
Note: See TracBrowser for help on using the browser.