#include <iostream>
#include "framecpp/FrameCPP.hh"
#include "framecpp/OFrameStream.hh"
#include "framecpp/IFrameStream.hh"

int main() {
    const std::string test_file = "/Users/efm/build/LDAS/ldas-tools/u/framecpp-prefix/src/framecpp-build/src/Utilities/test_fileBaseName.gwf";

    // Create output stream
    {
        FrameCPP::OFrameFStream ofs(test_file.c_str());
        auto toc = ofs.GetTOC();

        std::cout << "Before SetFileBaseName: '" << toc->GetFileBaseName() << "'" << std::endl;

        toc->SetFileBaseName("/some/path/to/myfile.gwf");

        std::cout << "After SetFileBaseName: '" << toc->GetFileBaseName() << "'" << std::endl;

        // Create a simple frame
        FrameCPP::FrameH frame("Test", 0, 0, FrameCPP::GPSTime(1234567890, 0), 1.0);
        ofs.WriteFrame(boost::shared_ptr<FrameCPP::FrameH>(&frame, [](FrameCPP::FrameH*){}));
    }

    // Read it back
    {
        FrameCPP::IFrameFStream ifs(test_file.c_str());
        auto toc = ifs.GetTOC();

        std::cout << "Read back fileBaseName: '" << toc->GetFileBaseName() << "'" << std::endl;
    }

    return 0;
}
