Program Listing for File Output.h

Return to documentation for file (include/crpropa/module/Output.h)

#ifndef CRPROPA_OUTPUT_H
#define CRPROPA_OUTPUT_H

#include "crpropa/Module.h"
#include "crpropa/Variant.h"

#include <bitset>
#include <vector>
#include <string>

namespace crpropa {

class Output: public Module {
protected:
        double lengthScale, energyScale;
        std::bitset<64> fields;

        struct Property
        {
                std::string name;
                std::string comment;
                Variant defaultValue;
        };
        std::vector<Property> properties;

        bool oneDimensional;
        mutable size_t count;

        void modify();

public:
        enum OutputColumn {
                TrajectoryLengthColumn,
                ColumnDensityColumn,
                RedshiftColumn,
                CurrentIdColumn,
                CurrentEnergyColumn,
                CurrentPositionColumn,
                CurrentDirectionColumn,
                SourceIdColumn,
                SourceEnergyColumn,
                SourcePositionColumn,
                SourceDirectionColumn,
                CreatedIdColumn,
                CreatedEnergyColumn,
                CreatedPositionColumn,
                CreatedDirectionColumn,
                CandidateTagColumn,
                SerialNumberColumn,
                WeightColumn
        };
        enum OutputType {
                Trajectory1D,
                Trajectory3D,
                Event1D,
                Event3D,
                Everything
        };

        std::string OutputTypeName(OutputType outputtype);
        const std::string outputName;

        Output();
        Output(OutputType outputType);

        void setEnergyScale(double scale);
        void setLengthScale(double scale);
        void setOutputType(OutputType outputType);
        void set(OutputColumn field, bool value);
        void enableProperty(const std::string &property, const Variant& defaultValue, const std::string &comment = "");
        void enable(OutputColumn field);
        void disable(OutputColumn field);
        void enableAll();
        void disableAll();
        void set1D(bool value);
        size_t size() const;

        void process(Candidate *) const;
};

} // namespace crpropa

#endif // CRPROPA_OUTPUT_H