File: ExampleReadPlugin.h

package info (click to toggle)
adios2 2.10.2%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 33,764 kB
  • sloc: cpp: 175,964; ansic: 160,510; f90: 14,630; yacc: 12,668; python: 7,275; perl: 7,126; sh: 2,825; lisp: 1,106; xml: 1,049; makefile: 579; lex: 557
file content (90 lines) | stat: -rw-r--r-- 2,715 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
 * Distributed under the OSI-approved Apache License, Version 2.0.  See
 * accompanying file Copyright.txt for details.
 *
 * ExampleReadPlugin.h Simple file reading engine for reading files written by
 * the ExampleWritePlugin engine. Looks for directory
 * (called "ExamplePlugin" by default, but can be changed with engine parameter
 * "DirName") and reads variable info from vars.txt and actual data from
 * data.txt.
 *
 *  Created on: Jul 5, 2021
 *      Author: Caitlin Ross <caitlin.ross@kitware.com>
 */

#ifndef EXAMPLEREADPLUGIN_H_
#define EXAMPLEREADPLUGIN_H_

#include "plugin_engine_read_export.h"

#include <fstream>
#include <string>

#include "adios2/common/ADIOSMacros.h"
#include "adios2/common/ADIOSTypes.h"
#include "adios2/core/IO.h"
#include "adios2/engine/plugin/PluginEngineInterface.h"
#include "adios2/helper/adiosComm.h"
#include "adios2/helper/adiosString.h"

namespace adios2
{
namespace plugin
{

/** An engine interface to be used by the plugin infrastructure */
class ExampleReadPlugin : public PluginEngineInterface
{
public:
    ExampleReadPlugin(core::IO &io, const std::string &name, const Mode openMode,
                      helper::Comm comm);
    virtual ~ExampleReadPlugin();

    /** Indicates beginning of a step **/
    StepStatus BeginStep(StepMode mode = StepMode::Read,
                         const float timeoutSeconds = -1.0) override;

    /** Indicates end of a step **/
    void EndStep() override;

    /** Return the current step **/
    size_t CurrentStep() const override;

    /** Execute deferred mode Gets **/
    void PerformGets() override;

protected:
    void Init() override;

#define declare(T)                                                                                 \
    void DoGetSync(core::Variable<T> &variable, T *values) override;                               \
    void DoGetDeferred(core::Variable<T> &variable, T *values) override;
    ADIOS2_FOREACH_STDTYPE_1ARG(declare)
#undef declare

    void DoClose(const int transportIndex = -1) override;

private:
    std::ifstream m_DataFile;
    std::ifstream m_VarFile;
    size_t m_CurrentStep = 0;

    template <typename T>
    void AddVariable(const std::string &name, Dims shape, Dims start, Dims count);

    template <class T>
    void ReadVariable(core::Variable<T> &variable, T *values);
};

} // end namespace plugin
} // end namespace adios2

extern "C" {

PLUGIN_ENGINE_READ_EXPORT adios2::plugin::ExampleReadPlugin *
EngineCreate(adios2::core::IO &io, const std::string &name, const adios2::Mode mode,
             adios2::helper::Comm comm);
PLUGIN_ENGINE_READ_EXPORT void EngineDestroy(adios2::plugin::ExampleReadPlugin *obj);
}

#endif /* EXAMPLEREADPLUGIN_H_ */