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%421040A40076.cm preserve=no
//## end module%421040A40076.cm

//## begin module%421040A40076.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%421040A40076.cp

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

//## begin module%421040A40076.additionalIncludes preserve=no
//## end module%421040A40076.additionalIncludes

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

// SequenceCollection
#include "SequenceCollection.h"
// Sequence
#include "Sequence.h"
//## begin module%421040A40076.additionalDeclarations preserve=yes
//## end module%421040A40076.additionalDeclarations


// Class SequenceCollection 

SequenceCollection::SequenceCollection()
  //## begin SequenceCollection::SequenceCollection%421040A40076_const.initialization preserve=yes
  //## end SequenceCollection::SequenceCollection%421040A40076_const.initialization
{
  //## begin SequenceCollection::SequenceCollection%421040A40076_const.body preserve=yes
  //## end SequenceCollection::SequenceCollection%421040A40076_const.body
}


SequenceCollection::~SequenceCollection()
{
  //## begin SequenceCollection::~SequenceCollection%421040A40076_dest.body preserve=yes

        clear();  

  //## end SequenceCollection::~SequenceCollection%421040A40076_dest.body
}



//## Other Operations (implementation)
//## Operation: clear%4211667202C7
void SequenceCollection::clear ()
{
  //## begin SequenceCollection::clear%4211667202C7.body preserve=yes

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

  //## end SequenceCollection::clear%4211667202C7.body
}

//## Operation: getCollection%4211952E0066
const std::map< std::string, Sequence * > & SequenceCollection::getCollection () const
{
  //## begin SequenceCollection::getCollection%4211952E0066.body preserve=yes

        return ( m_sequence );  

  //## end SequenceCollection::getCollection%4211952E0066.body
}

//## Operation: getSequence%4211667202D7
Sequence& SequenceCollection::getSequence (const std::string &sequenceName, const bool &persisted, const int &first)
{
  //## begin SequenceCollection::getSequence%4211667202D7.body preserve=yes

        std::map< std::string, Sequence * >::const_iterator
                instance = m_sequence.find( sequenceName );

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

                try
                {
                        object = new Sequence( sequenceName, first );

                        if ( m_sequence.insert(
                                        std::map< std::string, Sequence * >::value_type(
                                                sequenceName,
                                                object ) ).second )
                        {
                                object->setPersist( persisted );
                                return ( *object );
                        }
                        else
                        {
                                MTHROW( std::runtime_error, \
                                        "Cannot add sequence \"" \
                                        << sequenceName \
                                        << "\" to sequence collection." );
                        }
                }
                catch ( ... )
                {
                        delete object;
                        object = 0;

                        throw;
                }
        }

  //## end SequenceCollection::getSequence%4211667202D7.body
}

// Additional Declarations
  //## begin SequenceCollection%421040A40076.declarations preserve=yes
  //## end SequenceCollection%421040A40076.declarations

//## begin module%421040A40076.epilog preserve=yes
//## end module%421040A40076.epilog