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