root/juggler/tags/1.0.5/Kernel/vjQueuedConfigChunkHandler.cpp

Revision 2828, 6.1 kB (checked in by patrickh, 8 years ago)

Updated the copyright to what ISU's lawyers decided they want now.
The vast majority of this was done using Kevin's auto-copyright.pl script
which definitely made this easier. All the copyright blocks now have
begin and end tags so that if and when we have to update the copyright
information again, it will be even simpler.

  • 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 #include <vjConfig.h>
34 #include <Kernel/vjQueuedConfigChunkHandler.h>
35 #include <Kernel/vjKernel.h>
36
37 //: Add a database of config chunks
38 // Just loops through the chunks and calls configAdd for each one
39 bool vjQueuedConfigChunkHandler::configAddDB(vjConfigChunkDB* chunkDB)
40 {
41    // ---- DEPENDENCY SORT  ---- //
42    int dep_result = chunkDB->dependencySort(vjKernel::instance()->getChunkDB());
43
44    // If dependency sort fails, exit with error
45    if(dep_result == -1)
46    {
47       vjDEBUG(vjDBG_ERROR,0) << "vjQueuedConfiChunkHandler::processConfigAddQueue: ERROR: Dependency sort failed. Aborting add.\n" << vjDEBUG_FLUSH;
48       return false;
49    }
50
51    std::vector<vjConfigChunk*> sorted_chunks = chunkDB->getChunks();  // Get sorted list of chunks to add
52
53    //vjDEBUG_BEGIN(vjDBG_ALL,1) << "vjQueuedConfiChunkHandler: processConfigAddQueue: Processing chunks.\n" << vjDEBUG_FLUSH;
54    //std::vector<vjConfigChunk*> chunks = chunkDB->getChunks();
55
56    // For each element in chunk list
57    for (int i=0;i<sorted_chunks.size();i++)
58       configAdd(sorted_chunks[i]);
59
60    return true;
61 }
62
63 bool vjQueuedConfigChunkHandler::configRemoveDB(vjConfigChunkDB* chunkDB)
64 {
65    vjDEBUG_BEGIN(vjDBG_ALL,1) << "vjQueuedConfiChunkHandler: processConfigAddQueue: Processing chunks.\n" << vjDEBUG_FLUSH;
66
67    std::vector<vjConfigChunk*> chunks = chunkDB->getChunks();
68
69    // For each element in chunk list
70    for (int i=0;i<chunks.size();i++)
71       configRemove(chunks[i]);
72
73    return true;
74 }
75
76
77 void vjQueuedConfigChunkHandler::processConfigAddQueue()
78 {
79    vjDEBUG_BEGIN(vjDBG_ALL,1) << "vjQueuedConfiChunkHandler: processConfigAddQueue: Processing chunks.\n" << vjDEBUG_FLUSH;
80    //vjASSERT(vjThread::self() == mControlThread);      // ASSERT: We are being called from kernel thread
81
82    vjConfigChunk* chunk;     // Chunk db to add
83
84    while (!mConfigAddQueue.empty())
85    {
86       // -- GET CHUNK to work with -- //
87       chunk = mConfigAddQueue.front();
88       mConfigAddQueue.pop();
89       vjASSERT(chunk != NULL);
90
91       vjDEBUG(vjDBG_ALL,3) << "Processing chunk: " << chunk << endl << *chunk << vjDEBUG_FLUSH;
92
93       // --- ADD CHUNK -- //
94       bool added_chunk = false;        // Flag: true - chunk was added
95       added_chunk = processChunkAdd(chunk);      // PROCESS CHUNK
96
97       // --- ADD to ACTIVE CHUNKDB --- //
98       if (added_chunk)      // if added => add to config database
99       {
100          vjASSERT(chunk != NULL);
101          vjKernel::instance()->getChunkDB()->addChunk(chunk);    // Add to global DB
102          int num_chunks = vjKernel::instance()->getChunkDB()->getChunks().size();
103          vjDEBUG(vjDBG_ALL,1) << "vjQueuedConfiChunkHandler::processConfigAddQueue: Added chunk: " << chunk->getProperty("name") << ", Now have " << num_chunks << " chunks.\n" << vjDEBUG_FLUSH;
104       }
105       else                 // Else: Give unrecognized error
106       {
107          vjDEBUG(vjDBG_ALL,0) << "vjQueuedConfiChunkHandler::processConfigAddQueue: Unrecognized chunk.\n"
108          << "   type: " << chunk->getType() << endl << vjDEBUG_FLUSH;
109       }
110    }
111
112    // Tell the environment manager to refresh
113 //**//   environmentManager->sendRefresh();
114    vjDEBUG_END(vjDBG_ALL,1) << "vjQueuedConfiChunkHandler: configAdd: Done adding\n\n" << vjDEBUG_FLUSH;
115 }
116
117
118 void vjQueuedConfigChunkHandler::processConfigRemoveQueue()
119 {
120    //vjASSERT(vjThread::self() == mControlThread);      // ASSERT: We are being called from kernel thread
121    vjDEBUG_BEGIN(vjDBG_ALL,1) << "vjQueuedConfigChunkHandler: processConfigRemoveQueue: Removing chunk.\n" << vjDEBUG_FLUSH;
122
123    vjConfigChunk* chunk;
124
125    while(!mConfigRemoveQueue.empty())
126    {
127       chunk = mConfigRemoveQueue.front();
128       mConfigRemoveQueue.pop();
129       vjASSERT(chunk != NULL);
130
131       // Remove the chunk
132       bool removed_chunk = false;        // Flag: true - chunk was removed
133
134       // Find manager to handle them
135       removed_chunk = processChunkRemove(chunk);
136
137       // --- Check for removal from active config --- //
138       if(removed_chunk)      // if removed => remove from config database
139       {
140          vjASSERT(chunk != NULL);
141          vjKernel::instance()->getChunkDB()->removeNamed(chunk->getProperty("name"));
142          int num_chunks = vjKernel::instance()->getChunkDB()->getChunks().size();
143          vjDEBUG(vjDBG_ALL,3) << "vjQueuedConfigChunkHandler::processConfigRemoveQueue: Removed chunk: Now have " << num_chunks << " chunks.\n" << vjDEBUG_FLUSH;
144       }
145       else                 // Else: Give unrecognized error
146       {
147          vjDEBUG(vjDBG_ALL,0) << "vjQueuedConfigChunkHandler::processConfigRemoveQueue: Unrecognized chunk.\n"
148                     << "   type: " << chunk->getType() << endl << vjDEBUG_FLUSH;
149       }
150    }
151
152    vjDEBUG_END(vjDBG_ALL,1) << "vjQueuedConfigChunkHandler: processConfigRemoveQueue: Exiting.\n" << vjDEBUG_FLUSH;
153
154    // Tell the environment manager to refresh
155 //**//   environmentManager->sendRefresh();
156 }
Note: See TracBrowser for help on using the browser.