root/juggler/branches/1.0/Kernel/vjDependencyManager.h

Revision 8789, 3.7 kB (checked in by patrickh, 7 years ago)

Copyright update.

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