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

Revision 7539, 3.7 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_MGR_H_
35 #define _VJ_DEP_MGR_H_
36 //#pragma once
37
38 #include <vjConfig.h>
39 #include <Kernel/vjDepChecker.h>
40 #include <Config/vjConfigChunk.h>
41 #include <typeinfo>
42 #include <Utils/vjSingleton.h>
43
44
45 //: Object used for creating devices
46 //!NOTE: Singleton
47 class vjDependencyManager
48 {
49 private:
50    // Singleton so must be private
51    vjDependencyManager() : mDepCheckers(), mDefaultChecker()
52    {
53       mDepCheckers = std::vector<vjDepChecker*>(0);
54       vjASSERT(mDepCheckers.size() == 0);
55       //debugDump();
56    }
57
58 public:
59    // Called to register a new checker with the system
60    void registerChecker(vjDepChecker* checker)
61    {
62       vjASSERT(checker != NULL);
63       mDepCheckers.push_back(checker);          // Add the checker to the list
64       vjDEBUG(vjDBG_KERNEL,vjDBG_CONFIG_LVL)
65               << "vjDependencyManager: Registered: "
66               << std::setiosflags(std::ios::right) << std::setw(25) << std::setfill(' ') << checker->getCheckerName().c_str() << std::resetiosflags(std::ios::right)
67               << "  type: " << typeid(*checker).name() << std::endl
68               << vjDEBUG_FLUSH;
69       debugDump();
70    }
71
72
73
74    //: Are the dependencies satisfied for the given chunk?
75    //
76    //!RETURNS: true - dependencies are currently satisifed for the chunk
77    bool depSatisfied(vjConfigChunk* chunk)
78    {
79       vjASSERT(NULL != chunk);
80       vjDepChecker* checker = findDepChecker(chunk);
81       return checker->depSatisfied(chunk);
82    }
83
84    void debugOutDependencies(vjConfigChunk* chunk,int dbg_lvl)
85    {
86       vjASSERT(NULL != chunk);
87       vjDepChecker* checker = findDepChecker(chunk);
88       checker->debugOutDependencies(chunk,dbg_lvl);
89    }
90
91 private:
92    //: Returns a dependency checker for the given chunk
93    //! RETURNS: If checker found, it is returned
94    //+          Otherwise, it returns the default checker
95    vjDepChecker* findDepChecker(vjConfigChunk* chunk);
96
97    void debugDump();
98
99 private:
100    std::vector<vjDepChecker*> mDepCheckers;     //: List of the device constructors
101    vjDepChecker               mDefaultChecker;  //: The default checker
102
103 vjSingletonHeader(vjDependencyManager);
104 /*
105 public:     // ------ SINGLETON ----- ///
106    //: Return singleton instance of the class
107    static vjDependencyManager* instance()
108    {
109       if(mInstance == NULL)
110       {
111          mInstance = new vjDependencyManager();
112       }
113
114       return mInstance;
115    }
116
117 private:
118    static vjDependencyManager* mInstance;
119    */
120 };
121
122 #endif
123
Note: See TracBrowser for help on using the browser.