Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include generated files in repo #50

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/cpp/generated/
/cpp/build/
/python/petsird/
__pycache__/

# Common editor backups
Expand Down
16 changes: 16 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,19 @@ add_executable(petsird_analysis petsird_analysis.cpp)
target_link_libraries(petsird_analysis petsird_generated)

add_subdirectory(generated)

# PETSIRD Library (libpetsird)
add_library(petsird SHARED $<TARGET_OBJECTS:petsird_generated>)
target_link_libraries(petsird petsird_generated)
install(TARGETS petsird DESTINATION lib)

# Set the target include directory where headers will be installed
set(INSTALL_INCLUDE_DIR "include/petsird")

# Collect all header files in the current directory and subdirectories
file(GLOB_RECURSE HEADER_FILES "*.h")

# Specify the installation directory for header files
install(FILES ${HEADER_FILES}
DESTINATION ${INSTALL_INCLUDE_DIR}
)
40 changes: 40 additions & 0 deletions cpp/generated/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This file was generated by the "yardl" tool. DO NOT EDIT.

# To opt out of generating this file, set cpp.generateCMakeLists to false in the _package.yml file.

# To use the object library defined in this file, add the following to your CMakeLists.txt file:
# target_link_libraries(<your target> petsird_generated)
# add_subdirectory(<path to this directory>)

set(HOWARD_HINNANT_DATE_MINIMUM_VERSION "3.0.0")
find_package(date ${HOWARD_HINNANT_DATE_MINIMUM_VERSION} REQUIRED)

if(VCPKG_TARGET_TRIPLET)
set(HDF5_CXX_LIBRARIES hdf5::hdf5_cpp-shared)
else()
set(HDF5_CXX_LIBRARIES hdf5::hdf5_cpp)
endif()

set(HDF5_MINIMUM_VERSION "1.10.5")
find_package(HDF5 ${HDF5_MINIMUM_VERSION} REQUIRED COMPONENTS C CXX)

set(XTENSOR_MINIMUM_VERSION "0.21.10")
find_package(xtensor ${XTENSOR_MINIMUM_VERSION} REQUIRED)

set(NLOHMANN_JSON_MINIMUM_VERSION "3.11.1")
find_package(nlohmann_json ${NLOHMANN_JSON_MINIMUM_VERSION} REQUIRED)
add_library(petsird_generated OBJECT
protocols.cc
types.cc
ndjson/protocols.cc
binary/protocols.cc
hdf5/protocols.cc
)

target_link_libraries(petsird_generated
PUBLIC ${HDF5_C_LIBRARIES}
PUBLIC ${HDF5_CXX_LIBRARIES}
PUBLIC xtensor
PUBLIC date::date
PUBLIC nlohmann_json::nlohmann_json
)
1,158 changes: 1,158 additions & 0 deletions cpp/generated/binary/protocols.cc

Large diffs are not rendered by default.

61 changes: 61 additions & 0 deletions cpp/generated/binary/protocols.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// This file was generated by the "yardl" tool. DO NOT EDIT.

#pragma once
#include <array>
#include <complex>
#include <memory>
#include <optional>
#include <variant>
#include <vector>

#include "../protocols.h"
#include "../yardl/detail/binary/reader_writer.h"

namespace petsird::binary {
// Binary writer for the PETSIRD protocol.
// Definition of the stream of data
class PETSIRDWriter : public petsird::PETSIRDWriterBase, yardl::binary::BinaryWriter {
public:
PETSIRDWriter(std::ostream& stream, Version version = Version::Current)
: yardl::binary::BinaryWriter(stream, petsird::PETSIRDWriterBase::SchemaFromVersion(version)), version_(version) {}

PETSIRDWriter(std::string file_name, Version version = Version::Current)
: yardl::binary::BinaryWriter(file_name, petsird::PETSIRDWriterBase::SchemaFromVersion(version)), version_(version) {}

void Flush() override;

protected:
void WriteHeaderImpl(petsird::Header const& value) override;
void WriteTimeBlocksImpl(petsird::TimeBlock const& value) override;
void WriteTimeBlocksImpl(std::vector<petsird::TimeBlock> const& values) override;
void EndTimeBlocksImpl() override;
void CloseImpl() override;

Version version_;
};

// Binary reader for the PETSIRD protocol.
// Definition of the stream of data
class PETSIRDReader : public petsird::PETSIRDReaderBase, yardl::binary::BinaryReader {
public:
PETSIRDReader(std::istream& stream)
: yardl::binary::BinaryReader(stream), version_(petsird::PETSIRDReaderBase::VersionFromSchema(schema_read_)) {}

PETSIRDReader(std::string file_name)
: yardl::binary::BinaryReader(file_name), version_(petsird::PETSIRDReaderBase::VersionFromSchema(schema_read_)) {}

Version GetVersion() { return version_; }

protected:
void ReadHeaderImpl(petsird::Header& value) override;
bool ReadTimeBlocksImpl(petsird::TimeBlock& value) override;
bool ReadTimeBlocksImpl(std::vector<petsird::TimeBlock>& values) override;
void CloseImpl() override;

Version version_;

private:
size_t current_block_remaining_ = 0;
};

} // namespace petsird::binary
Loading