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

Revision 8789, 4.4 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 #ifndef _VJ_QUEUED_CONFIG_CHUNK_HANDLER_H_
35 #define _VJ_QUEUED_CONFIG_CHUNK_HANDLER_H_
36
37
38 #include <vjConfig.h>
39 #include <Kernel/vjDebug.h>
40 #include <Config/vjConfigChunk.h>
41 class vjConfigChunkDB;
42 #include <Sync/vjGuardedQueue.h>
43 #include <Kernel/vjConfigChunkHandler.h>
44
45 //: Class that holds configuration queues for the system objects
46 class vjQueuedConfigChunkHandler : public vjConfigChunkHandler
47 {
48 public:
49    // --- Chunk Databases --- //
50    //: Add a database of config chunks
51    // Just loops through the chunks and calls configAdd for each one
52    virtual bool configAddDB(vjConfigChunkDB* chunkDB);
53
54    //: Remove all config chunks in the given chunk db
55    virtual bool configRemoveDB(vjConfigChunkDB* chunkDB);
56
57    // ---- Inidividual chunks --- //
58    //: Add a config chunk
59    // Puts chunk into the add queue
60    virtual bool configAdd(vjConfigChunk* chunk)
61    {
62       vjDEBUG(vjDBG_ALL,1) << "vjQueuedConfigChunkHandler::configAdd: Adding chunk to add queue\n" << vjDEBUG_FLUSH;
63       vjDEBUG(vjDBG_ALL,4) << chunk << ":\n" << *chunk << endl << vjDEBUG_FLUSH;
64       mConfigAddQueue.push(chunk);
65       vjASSERT(chunk != NULL);
66       return true;
67    }
68
69    //: Remove a config chunk
70    // Puts chunk into the add queue
71    virtual bool configRemove(vjConfigChunk* chunk)
72    {
73       vjDEBUG(vjDBG_ALL,1) << "vjQueuedConfigChunkHandler::configRemove: Adding chunk to remove queue\n" << vjDEBUG_FLUSH;
74       vjDEBUG(vjDBG_ALL,4) << chunk << ":\n" << *chunk << endl << vjDEBUG_FLUSH;
75       mConfigRemoveQueue.push(chunk);
76       vjASSERT(chunk != NULL);
77       return true;
78    }
79
80
81    //: Check the queues and process any chunks found therein
82    //! NOTE: This should most likely only be called from the control thread of the object
83    void checkConfigQueues()
84    {
85       // ---- RECONFIGURATION --- //
86       if(!mConfigAddQueue.empty())
87          processConfigAddQueue();
88
89       if(!mConfigRemoveQueue.empty())
90          processConfigRemoveQueue();
91
92       // --- Ouput info --- //
93       outputQueueStats();
94    }
95
96    void outputQueueStats()
97    {
98       int add_size = mConfigAddQueue.size();
99       int remove_size = mConfigRemoveQueue.size();
100       if((add_size != 0) && (remove_size != 0))
101       {
102          vjDEBUG(vjDBG_ALL,0) << "addQueue:    size: " << add_size << endl << vjDEBUG_FLUSH;
103          vjDEBUG(vjDBG_ALL,0) << "removeQueue: size: " << remove_size << endl << vjDEBUG_FLUSH;
104       }
105    }
106
107 protected:
108    //: Takes any chunks in add queue and adds them to running system
109    void processConfigAddQueue();
110
111    //: Takes any chunks in remove queue and reconfigures system by removing them
112    void processConfigRemoveQueue();
113
114
115    //: Take care of adding a single chunk
116    //! RETVAL: true - Chunk has been added
117    virtual bool processChunkAdd(vjConfigChunk* chunk) = 0;
118
119    //: Take care of removing a single chunk
120    //! RETVAL: true - Chunk has been added
121    virtual bool processChunkRemove(vjConfigChunk* chunk) = 0;
122
123 protected:
124    vjGuardedQueue<vjConfigChunk*> mConfigAddQueue;      //: A queue of chunDB's to reconfig from
125    vjGuardedQueue<vjConfigChunk*> mConfigRemoveQueue;   //: A queue of chunkDB's to remove
126 };
127
128 #endif
129
Note: See TracBrowser for help on using the browser.