Example #1
0
/**
 * processItem
 *    - If this is a TclCommand - flush all the consolidations and output.
 *    - If there's already a consolidation for  this type if the message is the
 *      same just count it, otherwise flush and set a new consolidation.
 *    - If there's not an existing consolidation, make one.
 *    - free storage associated with the action item's payload.
 *
 *    @param action - action message.
 */
void
Actions::COutputThread::processItem(Actions::ActionItem item)
{
    Actions::ActionType type = item.s_type;
    std::string        msg  = item.s_pMessage;
    free(item.s_pMessage);                 // Free storage!'
    
    if (type == Actions::TclCommand) {
        flushMessages();                // Flush All messages before commanding.
        outputItem(type, msg);
    } else {
        //  Message, not an actual 'action'.
        
        std::map<Actions::ActionType, ActionInfo>::iterator p =
            m_ConsolidatedActions.find(type);
        if (p == m_ConsolidatedActions.end()) {     // No prior message.
            createConsolidation(type, msg);
        } else {
            if(msg == p->second.s_message) {          // If repetition
                p->second.s_messageCount++; // count.
            } else {
                flushItem(type);                     // otherwise flush  that item.
                createConsolidation(type, msg);    // start a new one.
            }
        }
    }
}
Example #2
0
void TDBCache::removeFromFile( RecordDescriptor *descriptor )
{
	RecordDescriptor *d = get( descriptor );

	if( d )
		flushItem( d );

	file->deleteRecord( descriptor );
}
Example #3
0
/**
 * flushMessages
 *    Flush all messages in he map.  Note we flush in increasing
 *    Severity.
 */
void
Actions::COutputThread::flushMessages()
{
    Actions::ActionType actionOrder[] = {
        Actions::DebugMessage, Actions::OutputMessage,  Actions::LogMessage,
        Actions::WarningMessage, Actions::ErrorMessage
    };
    unsigned numActions = sizeof(actionOrder)/sizeof(Actions::ActionType);
    
    for (int  i = 0; i < numActions; i++) {
        flushItem(actionOrder[i]);
    }
}
Example #4
0
void TDBCache::insertIntoFile( RecordDescriptor *descriptor, void *item )
{
	file->createRecord( descriptor );
	file->writeRecord( descriptor, item );

	if( items->getCount() == limit )
		flushItem( items->at( 0 ) );

	items->insert( item );

	RecordDescriptor *d = new RecordDescriptor;
	*d = *descriptor;
	descriptors->insert( d );
}
Example #5
0
void *TDBCache::getItem( RecordDescriptor *descriptor )
{
	RecordDescriptor *d = get( descriptor );
	if( d )
		return items->at( descriptors->indexOf( d ) );
	else
		{
		if( items->getCount() == limit )
			flushItem( items->at( 0 ) );

		void *item = file->readRecord( descriptor, this );

		items->insert( item );

		d = new RecordDescriptor;
		*d = *descriptor;
		descriptors->insert( d );

		return item;
		}
}
Example #6
0
void TDBCache::flushItem( void *item )
{
	flushItem(
		(RecordDescriptor *)descriptors->at( items->indexOf( item ) ) );
}
Example #7
0
void TDBCache::flush()
{
	while( items->getCount() > 0 )
		flushItem( items->at( 0 ) );
}