Skip to content
Snippets Groups Projects
BPFileReader.h 2.13 KiB
Newer Older
wfg's avatar
wfg committed
/*
 * Distributed under the OSI-approved Apache License, Version 2.0.  See
 * accompanying file Copyright.txt for details.
 *
wgodoy's avatar
wgodoy committed
 * BPFileReader.h
wfg's avatar
wfg committed
 *
 *  Created on: Feb 27, 2017
wgodoy's avatar
wgodoy committed
 *      Author: William F Godoy godoywf@ornl.gov
wfg's avatar
wfg committed
 */

#ifndef ADIOS2_ENGINE_BP_BPFILEREADER_H_
#define ADIOS2_ENGINE_BP_BPFILEREADER_H_
wfg's avatar
wfg committed

#include "adios2/ADIOSConfig.h"
#include "adios2/core/Engine.h"
#include "adios2/toolkit/format/bp3/BP3.h" //format::BP1Deserializer
#include "adios2/toolkit/transportman/TransportMan.h"
wfg's avatar
wfg committed

namespace adios2
namespace utils
{
class BPLS2;
}

wfg's avatar
wfg committed
class BPFileReader : public Engine
    friend class utils::BPLS2;

wfg's avatar
wfg committed
public:
     * Unique constructor
     * @param io
     * @param name
     * @param openMode only read
     * @param mpiComm
William F Godoy's avatar
William F Godoy committed
    BPFileReader(IO &io, const std::string &name, const Mode mode,
wgodoy's avatar
wgodoy committed
                 MPI_Comm mpiComm);

    virtual ~BPFileReader() = default;

    StepStatus BeginStep(StepMode mode = StepMode::NextAvailable,
                         const float timeoutSeconds = 0.f) final;

    void EndStep() final;

    void PerformGets() final;

wgodoy's avatar
wgodoy committed
    void Close(const int transportIndex = -1);

private:
    format::BP3Deserializer m_BP3Deserializer;
    transportman::TransportMan m_FileManager;
    transportman::TransportMan m_SubFileManager;
    /** updates if step=1 in EndStep function, used for per-step reads */
    size_t m_CurrentStep = 0;

    void Init();
    void InitTransports();
    void InitBuffer();

#define declare_type(T)                                                        \
    void DoGetSync(Variable<T> &, T *) final;                                  \
    void DoGetDeferred(Variable<T> &, T *) final;                              \
    void DoGetDeferred(Variable<T> &, T &) final;
    ADIOS2_FOREACH_TYPE_1ARG(declare_type)
#undef declare_type

    template <class T>
    void GetSyncCommon(Variable<T> &variable, T *data);

    template <class T>
    void GetDeferredCommon(Variable<T> &variable, T *data);

    void
    ReadVariables(IO &io,
                  const std::map<std::string, SubFileInfoMap> &variablesInfo);
wfg's avatar
wfg committed
};

} // end namespace adios2
wfg's avatar
wfg committed

#endif /* ADIOS2_ENGINE_BP_BPFILEREADER_H_ */