Subversion Repositories DevTools

Rev

Blame | Last modification | View Log | RSS feed

//## begin module%1.7%.codegen_version preserve=yes
//   Read the documentation to learn more about C++ code generator
//   versioning.
//## end module%1.7%.codegen_version

//## begin module%4200A1030116.cm preserve=no
//## end module%4200A1030116.cm

//## begin module%4200A1030116.cp preserve=no
//      C O P Y R I G H T   N O T I C E
//      This material is confidential to ERG and may not be disclosed in whole
//      or in part to any third party nor used in any manner whatsoever other
//      than for the purposes expressly consented to by ERG in writing.
//
//      This material is also copyright and may not be reproduced, stored in a
//      retrieval system or transmitted in any form or by any means in whole or
//      in part without the express written consent of ERG.
//## end module%4200A1030116.cp

//## Module: TransactionCache%4200A1030116; Pseudo Package body
//## Subsystem: MASS::Dev::Tools::TxnTestManager::src%41F5A79001E4
//## Source file: Z:\MASS_Dev\Tools\TxnTestManager\src\TransactionCache.cpp

//## begin module%4200A1030116.additionalIncludes preserve=no
//## end module%4200A1030116.additionalIncludes

//## begin module%4200A1030116.includes preserve=yes
#pragma warn -com
#include <LoggingMacros.h>
#pragma warn +com
//## end module%4200A1030116.includes

// TransactionSpecification
#include "TransactionSpecification.h"
// TransactionCache
#include "TransactionCache.h"
//## begin module%4200A1030116.additionalDeclarations preserve=yes
//## end module%4200A1030116.additionalDeclarations


// Class TransactionCache 

TransactionCache::TransactionCache()
  //## begin TransactionCache::TransactionCache%4200A1030116_const.initialization preserve=yes
  //## end TransactionCache::TransactionCache%4200A1030116_const.initialization
{
  //## begin TransactionCache::TransactionCache%4200A1030116_const.body preserve=yes
  //## end TransactionCache::TransactionCache%4200A1030116_const.body
}


TransactionCache::~TransactionCache()
{
  //## begin TransactionCache::~TransactionCache%4200A1030116_dest.body preserve=yes

        clear();  

  //## end TransactionCache::~TransactionCache%4200A1030116_dest.body
}



//## Other Operations (implementation)
//## Operation: clear%4200A24E0286
void TransactionCache::clear ()
{
  //## begin TransactionCache::clear%4200A24E0286.body preserve=yes

        for ( std::map< int, TransactionSpecification * >::iterator
                        where = m_transaction.begin();
                  where != m_transaction.end();
                  ++where )
        {
                delete where->second;
                where->second = 0;
        }
        m_transaction.clear();

  //## end TransactionCache::clear%4200A24E0286.body
}

//## Operation: deleteTransactionSpecification%4200A5AC0008
void TransactionCache::deleteTransactionSpecification (const int &transaction)
{
  //## begin TransactionCache::deleteTransactionSpecification%4200A5AC0008.body preserve=yes

        m_transaction.erase( transaction );

  //## end TransactionCache::deleteTransactionSpecification%4200A5AC0008.body
}

//## Operation: getTransactionSpecification%4200A222003B
TransactionSpecification & TransactionCache::getTransactionSpecification (const int &transaction)
{
  //## begin TransactionCache::getTransactionSpecification%4200A222003B.body preserve=yes

        std::map< int, TransactionSpecification * >::const_iterator
                instance = m_transaction.find( transaction );

        if ( instance != m_transaction.end() )
        {
                return ( *instance->second );
        }
        else
        {
                TransactionSpecification * object = 0;

                try
                {
                        object = new TransactionSpecification( transaction );

                        if ( m_transaction.insert(
                                        std::map< int, TransactionSpecification * >::value_type(
                                                transaction,
                                                object ) ).second )
                        {
                                return ( *object );
                        }
                        else
                        {
                                MTHROW( std::runtime_error, \
                                        "Cannot add transaction \"" \
                                        << transaction \
                                        << "\" to cache." );
                        }
                }
                catch ( ... )
                {
                        delete object;
                        object = 0;

                        throw;
                }
        }

  //## end TransactionCache::getTransactionSpecification%4200A222003B.body
}

//## Operation: isContained%4200A2850361
const bool TransactionCache::isContained (const int &transaction) const
{
  //## begin TransactionCache::isContained%4200A2850361.body preserve=yes

        return ( m_transaction.find( transaction ) != m_transaction.end() );

  //## end TransactionCache::isContained%4200A2850361.body
}

// Additional Declarations
  //## begin TransactionCache%4200A1030116.declarations preserve=yes
  //## end TransactionCache%4200A1030116.declarations

//## begin module%4200A1030116.epilog preserve=yes
//## end module%4200A1030116.epilog