Subversion Repositories DevTools

Rev

Rev 2267 | Blame | Compare with Previous | 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%420720460243.cm preserve=no
//## end module%420720460243.cm

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

//## Module: TransactionStream%420720460243; Pseudo Package specification
//## Subsystem: MASS::Dev::Tools::TxnTestManager::src%41F5A79001E4
//## Source file: Z:\MASS_Dev\Tools\TxnTestManager\src\TransactionStream.h

#ifndef TransactionStream_h
#define TransactionStream_h 1

//## begin module%420720460243.additionalIncludes preserve=no
//## end module%420720460243.additionalIncludes

//## begin module%420720460243.includes preserve=yes
#include <fstream>
#include <string>

//## end module%420720460243.includes


class UdFileManifest;

//## begin module%420720460243.additionalDeclarations preserve=yes
//## end module%420720460243.additionalDeclarations


//## begin TransactionStream%420720460243.preface preserve=yes
//## end TransactionStream%420720460243.preface

//## Class: TransactionStream%420720460243; private
//      A stream of transactions.
//## Category: TransactionTestManager::Transaction Generation%4202F8EE0128
//## Subsystem: MASS::Dev::Tools::TxnTestManager::src%41F5A79001E4
//## Persistence: Transient
//## Cardinality/Multiplicity: n



class TransactionStream 
{
  //## begin TransactionStream%420720460243.initialDeclarations preserve=yes
  //## end TransactionStream%420720460243.initialDeclarations

  public:
    //## Constructors (specified)
      //## Operation: TransactionStream%4207228700FB
      //        The only constructor.
      TransactionStream (const std::string &folder,     // The folder in the file-system into which to write the transaction stream.
      const std::string &batchPrefix,   // The prefix given to batch filenames opened by this instance.
      const std::string &batchSuffix,   // The suffix given to batch filenames opened by this instance.
      const bool &buildManifest = true,         // When true, build a manifest of the files created by this stream, otherwise
        // don't build a manifest.
      const std::string &manifestPrefix = "udMan",      // The prefix given to manifest filenames opened by this instance.
      const std::string &manifestSuffix = ".txt",       // The suffix given to manifest filenames opened by this instance.
      const std::string &pathmapTarget = ""     // The folder in the file-system that shall contain the drain file.
      );

    //## Destructor (generated)
      virtual ~TransactionStream();


    //## Other Operations (specified)
      //## Operation: buildFileName%420821AD02EF
      //        Build a filename for naming transaction stream files, and evaluate to it.
      static std::string & buildFileName (std::string &filename,        // The value to which this method evaluates, and which shall hold the built
        // filename.
      const std::string &folder,        // The folder in the file-system into which to write the file.
      const std::string &prefix,        // The prefix asigned to this filename.
      const std::string &suffix,        // The suffix asigned to this filename.
      const std::string &batchName,     // The name of this batch.  When passing a string of zero-length, the batch is
        // not named.
      const unsigned &batchNumber       // The batch number.
      );

      //## Operation: incrementCount%420723C60224
      //        Increment the number of transactions that have been written into the
      //        stream.  When the current batch is full, the batch number is incremented and
      //        another batch is opened.
      void incrementCount ();

      //## Operation: newBatch%420722B50215
      //        Open a new batch of the given batch size, and evaluate to true, or false
      //        when a new batch cannot be opened.  The current batch number is reset to 1
      //        when the new batch is opened.
      const bool newBatch (const unsigned &size,        // The number of transactions that make up a batch.  When setting batch size
        // to 0, the stream is not batched; i.e., it is a continuous stream of
        // transactions.
      const std::string &name   // The name of this batch.  When passing a string of zero-length, the batch is
        // not named.
      );

      //## Operation: write%4207231D014A
      //        Write the given structure into the stream and evaluate to true, and to false
      //        when the structure cannot be written into the stream.  As transactions may
      //        comprise of multiple structures, we must rely on the caller to increment the
      //        transaction count.
      const bool write (const void *buffer,     // The starting address of the buffer that contains the structure to be
        // written into the stream.
      const unsigned &length    // The number of bytes contained in the buffer.
      );

    // Additional Public Declarations
      //## begin TransactionStream%420720460243.public preserve=yes
      //## end TransactionStream%420720460243.public
      //        Add info to the manifest.
      const void logToManifest (const std::string &info,  const bool &addTime );


  protected:
    // Additional Protected Declarations
      //## begin TransactionStream%420720460243.protected preserve=yes
      //## end TransactionStream%420720460243.protected

  private:
    //## Constructors (generated)
      TransactionStream();

      TransactionStream(const TransactionStream &right);

    //## Assignment Operation (generated)
      TransactionStream & operator=(const TransactionStream &right);


    //## Other Operations (specified)
      //## Operation: close%420819C203E4
      //        Close the transaction stream.
      void close ();

      //## Operation: open%420819AE03C4
      //        Open the transaction stream.
      const bool open ();

    // Data Members for Class Attributes

      //## Attribute: batchNumber%420722630244
      //        The current batch number.
      //## begin TransactionStream::batchNumber%420722630244.attr preserve=no  private: unsigned {VA} 1
      unsigned m_batchNumber;
      //## end TransactionStream::batchNumber%420722630244.attr

      //## Attribute: batchCount%4207240B0186
      //        The number of transactions that have been written to the current batch.
      //## begin TransactionStream::batchCount%4207240B0186.attr preserve=no  private: unsigned {VA} 0
      unsigned m_batchCount;
      //## end TransactionStream::batchCount%4207240B0186.attr

      //## Attribute: batchName%42084F7F0094
      //        When a non-zero-length string, this defines the name of the batch.
      //## begin TransactionStream::batchName%42084F7F0094.attr preserve=no  private: std::string {VA} 
      std::string m_batchName;
      //## end TransactionStream::batchName%42084F7F0094.attr

      //## Attribute: batchPrefix%42081637001D
      //        The prefix given to batch filenames opened by this instance.
      //## begin TransactionStream::batchPrefix%42081637001D.attr preserve=no  private: std::string {VA} batchPrefix
      std::string m_batchPrefix;
      //## end TransactionStream::batchPrefix%42081637001D.attr

      //## Attribute: batchSize%420720DA032E
      //        The number of transactions that make up a batch.  When setting batch size to
      //        0, the stream is not batched; i.e., it is a continuous stream of
      //        transactions.
      //## begin TransactionStream::batchSize%420720DA032E.attr preserve=no  private: unsigned {VA} 0
      unsigned m_batchSize;
      //## end TransactionStream::batchSize%420720DA032E.attr

      //## Attribute: batchSuffix%420724ED01A6
      //        The suffix given to batch filenames opened by this instance.
      //## begin TransactionStream::batchSuffix%420724ED01A6.attr preserve=no  private: std::string {VA} batchSuffix
      std::string m_batchSuffix;
      //## end TransactionStream::batchSuffix%420724ED01A6.attr

      //## Attribute: folder%420720B3005F
      //        The folder in the file-system to which we write the transaction stream.
      //## begin TransactionStream::folder%420720B3005F.attr preserve=no  private: std::string {VA} folder
      std::string m_folder;
      //## end TransactionStream::folder%420720B3005F.attr

      //## Attribute: stream%42081DC203B0
      //        The underlying stream currently open for writing.
      //## begin TransactionStream::stream%42081DC203B0.attr preserve=no  private: std::ofstream {RA} 0
      std::ofstream *m_stream;
      //## end TransactionStream::stream%42081DC203B0.attr

    // Data Members for Associations

      //## Association: TransactionTestManager::Transaction Generation::<unnamed>%4209BA7B01B4
      //## Role: TransactionStream::manifest%4209BA7B0389
      //        The instance that builds a manifest, when the stream is to build a manifest.
      //## begin TransactionStream::manifest%4209BA7B0389.role preserve=no  private: UdFileManifest {1 -> 1RFHgAN}
      UdFileManifest *m_manifest;
      //## end TransactionStream::manifest%4209BA7B0389.role

    // Additional Private Declarations
      //## begin TransactionStream%420720460243.private preserve=yes
      //## end TransactionStream%420720460243.private

  private: //## implementation
    // Additional Implementation Declarations
      //## begin TransactionStream%420720460243.implementation preserve=yes
      std::string m_filename;
      //## end TransactionStream%420720460243.implementation

};

//## begin TransactionStream%420720460243.postscript preserve=yes
//## end TransactionStream%420720460243.postscript

// Class TransactionStream 

//## begin module%420720460243.epilog preserve=yes
//## end module%420720460243.epilog


#endif