* tdm_termite: fix copy/assignment for cython-build

* setup.py: version 1.0.0
This commit is contained in:
Mario Fink 2021-05-04 18:29:02 +02:00
parent caae8be862
commit 0d6fd6545f
3 changed files with 61 additions and 8 deletions

View File

@ -6,20 +6,71 @@
tdm_termite::tdm_termite()
{
tdx_ifstream_ = new std::ifstream;
}
tdm_termite::tdm_termite(std::string tdmfile, std::string tdxfile, bool showlog):
tdmfile_(tdmfile), tdxfile_(tdxfile)
{
tdx_ifstream_ = new std::ifstream;
// start processing tdm data model
this->process_tdm(showlog);
}
tdm_termite::~tdm_termite()
{
// close tdx-file stream
tdx_ifstream_.close();
// close tdx-file stream and free memory
if ( tdx_ifstream_->is_open() ) tdx_ifstream_->close();
delete tdx_ifstream_;
}
tdm_termite::tdm_termite(const tdm_termite& other):
tdmfile_(other.tdmfile_), tdxfile_(other.tdxfile_), csvfile_(other.csvfile_),
endianness_(other.endianness_), machine_endianness_(other.machine_endianness_),
meta_data_(other.meta_data_), tdmdt_name_(other.tdmdt_name_),
tdmdt_chan_(other.tdmdt_chan_),
tdx_blocks_(other.tdx_blocks_), tdmroot_(other.tdmroot_),
tdmchannelgroups_(other.tdmchannelgroups_), tdmchannels_(other.tdmchannels_),
tdmchannels_data_(other.tdmchannels_data_), submatrices_(other.submatrices_),
localcolumns_(other.localcolumns_), tdxbuffer_(other.tdxbuffer_)
{
tdx_ifstream_ = new std::ifstream;
if ( other.tdx_ifstream_->is_open() )
{
tdx_ifstream_->open(tdxfile_.c_str(),std::ifstream::binary);
tdx_ifstream_->seekg(other.tdx_ifstream_->tellg());
}
}
tdm_termite& tdm_termite::operator=(const tdm_termite& other)
{
if ( this != &other )
{
tdmfile_ = other.tdmfile_;
tdxfile_ = other.tdxfile_;
csvfile_ = other.csvfile_;
endianness_ = other.endianness_;
machine_endianness_ = other.machine_endianness_;
meta_data_ = other.meta_data_;
tdmdt_name_ = other.tdmdt_name_;
tdmdt_chan_= other.tdmdt_chan_;
tdx_blocks_ = other.tdx_blocks_;
tdmroot_ = other.tdmroot_;
tdmchannelgroups_ = other.tdmchannelgroups_;
tdmchannels_ = other.tdmchannels_;
tdmchannels_data_ = other.tdmchannels_data_;
submatrices_ = other.submatrices_;
localcolumns_ = other.localcolumns_;
tdxbuffer_ = other.tdxbuffer_;
if ( other.tdx_ifstream_->is_open() )
{
tdx_ifstream_->open(tdxfile_.c_str(),std::ifstream::binary);
tdx_ifstream_->seekg(other.tdx_ifstream_->tellg());
}
}
return *this;
}
void tdm_termite::submit_files(std::string tdmfile, std::string tdxfile, bool showlog)
@ -129,7 +180,7 @@ void tdm_termite::process_tdm(bool showlog)
// + e.what() );
// }
try {
tdx_ifstream_.open(tdxfile_.c_str(),std::ifstream::binary);
tdx_ifstream_->open(tdxfile_.c_str(),std::ifstream::binary);
} catch (const std::exception& e) {
throw std::runtime_error( std::string("failed to open .tdx file in ifstream: ")
+ e.what() );
@ -602,8 +653,8 @@ std::vector<tdmdatatype> tdm_termite::get_channel(std::string& id)
// tdxbuffer_.begin()+fnshidx );
char* blkbuf = new char[blk.length_*dtyp.size_];
try {
tdx_ifstream_.seekg(strtidx);
tdx_ifstream_.read(blkbuf,blk.length_*dtyp.size_);
tdx_ifstream_->seekg(strtidx);
tdx_ifstream_->read(blkbuf,blk.length_*dtyp.size_);
} catch (const std::exception& e) {
throw std::runtime_error( std::string("failed to read block from tdx_ifstream_: ")
+ e.what() );

View File

@ -62,7 +62,7 @@ class tdm_termite
// binary data container/file stream
std::vector<unsigned char> tdxbuffer_;
std::ifstream tdx_ifstream_;
std::ifstream *tdx_ifstream_;
// extract list of identifiers from e.g. "#xpointer(id("usi12") id("usi13"))"
std::vector<std::string> extract_ids(std::string idstring)
@ -123,6 +123,8 @@ public:
tdm_termite(std::string tdmfile, std::string tdxfile = std::string(""),
bool showlog = false);
~tdm_termite();
tdm_termite(const tdm_termite& other);
tdm_termite& operator=(const tdm_termite& other);
// provide (tdm,tdx) files
void submit_files(std::string tdmfile, std::string tdxfile = std::string(""),

View File

@ -7,7 +7,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
setup(
name="TDMtermite",
version="0.5.0", #version,
version=1.0.0", #version,
author="Record Evolution GmbH",
author_email="mario.fink@record-evolution.de",
maintainer="Record Evolution GmbH",