| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
#include <vjConfig.h> |
|---|
| 34 |
#include <Kernel/vjQueuedConfigChunkHandler.h> |
|---|
| 35 |
#include <Kernel/vjKernel.h> |
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
bool vjQueuedConfigChunkHandler::configAddDB(vjConfigChunkDB* chunkDB) |
|---|
| 40 |
{ |
|---|
| 41 |
|
|---|
| 42 |
int dep_result = chunkDB->dependencySort(vjKernel::instance()->getChunkDB()); |
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 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(); |
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 81 |
|
|---|
| 82 |
vjConfigChunk* chunk; |
|---|
| 83 |
|
|---|
| 84 |
while (!mConfigAddQueue.empty()) |
|---|
| 85 |
{ |
|---|
| 86 |
|
|---|
| 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 |
|
|---|
| 94 |
bool added_chunk = false; |
|---|
| 95 |
added_chunk = processChunkAdd(chunk); |
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
if (added_chunk) |
|---|
| 99 |
{ |
|---|
| 100 |
vjASSERT(chunk != NULL); |
|---|
| 101 |
vjKernel::instance()->getChunkDB()->addChunk(chunk); |
|---|
| 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 |
|---|
| 106 |
{ |
|---|
| 107 |
vjDEBUG(vjDBG_ALL,0) << "vjQueuedConfiChunkHandler::processConfigAddQueue: Unrecognized chunk.\n" |
|---|
| 108 |
<< " type: " << chunk->getType() << endl << vjDEBUG_FLUSH; |
|---|
| 109 |
} |
|---|
| 110 |
} |
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
vjDEBUG_END(vjDBG_ALL,1) << "vjQueuedConfiChunkHandler: configAdd: Done adding\n\n" << vjDEBUG_FLUSH; |
|---|
| 115 |
} |
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
void vjQueuedConfigChunkHandler::processConfigRemoveQueue() |
|---|
| 119 |
{ |
|---|
| 120 |
|
|---|
| 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 |
|
|---|
| 132 |
bool removed_chunk = false; |
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
removed_chunk = processChunkRemove(chunk); |
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 |
if(removed_chunk) |
|---|
| 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 |
|---|
| 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 |
|
|---|
| 155 |
|
|---|
| 156 |
} |
|---|