Skip to content
Snippets Groups Projects
Transport.h 2.3 KiB
Newer Older
wfg's avatar
wfg committed
/*
wfg's avatar
wfg committed
 *
 *  Created on: Oct 6, 2016
 *      Author: wfg
 */

#ifndef TRANSPORT_H_
#define TRANSPORT_H_
/// \cond EXCLUDE_FROM_DOXYGEN
wfg's avatar
wfg committed
#include <string>
#include <vector>

#ifdef HAVE_MPI
    #include <mpi.h>
#else
    #include "../mpidummy.h"
wfg's avatar
wfg committed
namespace adios
{

    const std::string m_Method; ///< transport method name
wfg's avatar
wfg committed
    #ifdef HAVE_MPI
    MPI_Comm m_MPIComm = NULL; ///< only used as reference to MPI communicator passed from parallel constructor, MPI_Comm is a pointer itself. Public as called from C
    #else
    MPI_Comm m_MPIComm = 0; ///< only used as reference to MPI communicator passed from parallel constructor, MPI_Comm is a pointer itself. Public as called from C
    #endif

    //const unsigned int m_Iterations; ///< iteration number for this transport
    const bool m_DebugMode; ///< if true: additional checks and exceptions
    int m_MPIRank = 0; ///< current MPI rank process
    int m_MPISize = 1; ///< current MPI processes size
    /**
     * Base constructor that all derived classes pass
wfg's avatar
wfg committed
     * @param mpiComm passed to m_MPIComm
     * @param debugMode passed to m_DebugMode
     */
    Transport( const std::string method, MPI_Comm mpiComm, const bool debugMode );
    virtual ~Transport( ); ///< empty destructor, using STL for memory management
    /**
     * Open Output file accesing a mode
wfg's avatar
wfg committed
     * @param streamName name of file
     * @param accessMode r or read, w or write, a or append
     */
wfg's avatar
wfg committed
    virtual void Open( const std::string streamName, const std::string accessMode ) = 0;

    /**
     * Sets the buffer and bufferSize for certain transport methods
     * @param buffer to be set to transport
     */
    virtual void SetBuffer( std::vector<char>& buffer );
    /**
     * Write function for a transport, only called if required
     * @param buffer
     */
    virtual void Write( std::vector<char>& buffer );
    virtual void Close( ) = 0; ///< closes current transport and flushes everything, can't be reachable after this call
    /**
     * Initialize particular derived transport class members
     * @param arguments particular transport arguments from ADIOS Open variadic function
     */
    virtual void Init( const std::vector<std::string>& arguments );
#endif /* TRANSPORT_H_ */