Skip to content
Merged
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
6 changes: 6 additions & 0 deletions include/ezc3d/Analogs.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ class EZC3D_VISIBILITY ezc3d::DataNS::AnalogsNS::Analogs {
EZC3D_API Analogs(ezc3d::c3d &c3d, std::fstream &file,
const AnalogsNS::Info &info);

///
/// \brief Create a deep copy of an Analogs class
/// \return A deep copy of the Analogs class
///
EZC3D_API Analogs clone() const;

//---- STREAM ----//
public:
///
Expand Down
7 changes: 7 additions & 0 deletions include/ezc3d/AnalogsSubframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ class EZC3D_VISIBILITY ezc3d::DataNS::AnalogsNS::SubFrame {
EZC3D_API SubFrame(ezc3d::c3d &c3d, std::fstream &file,
const AnalogsNS::Info &info);

///
/// \brief Create a deep copy of a subframe
/// \param subframe The subframe to copy
/// \return A deep copy of the subframe
///
EZC3D_API SubFrame clone() const;

//---- STREAM ----//
public:
///
Expand Down
6 changes: 6 additions & 0 deletions include/ezc3d/Channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ class EZC3D_VISIBILITY ezc3d::DataNS::AnalogsNS::Channel {
EZC3D_API Channel(ezc3d::c3d &c3d, std::fstream &file,
const AnalogsNS::Info &info, size_t channelIndex);

///
/// \brief Create a deep copy of a channel
/// \return A deep copy of the channel
///
EZC3D_API Channel clone() const;

//---- STREAM ----//
public:
///
Expand Down
6 changes: 6 additions & 0 deletions include/ezc3d/Data.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ class EZC3D_VISIBILITY ezc3d::DataNS::Data {
///
EZC3D_API Data(ezc3d::c3d &c3d, std::fstream &file);

///
/// \brief Create a deep copy of a Data
/// \return A deep copy of the Data
///
EZC3D_API Data clone() const;

//---- STREAM ----//
public:
///
Expand Down
6 changes: 6 additions & 0 deletions include/ezc3d/Frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ class EZC3D_VISIBILITY ezc3d::DataNS::Frame {
///
EZC3D_API Frame();

///
/// \brief Create a deep copy of a frame
/// \param frame The frame to copy
///
EZC3D_API Frame clone() const;

//---- STREAM ----//
public:
///
Expand Down
6 changes: 6 additions & 0 deletions include/ezc3d/Group.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ class EZC3D_VISIBILITY ezc3d::ParametersNS::GroupNS::Group {
EZC3D_API Group(const std::string &name = "",
const std::string &description = "");

///
/// \brief Create a deep copy of a group of parameter
/// \return A deep copy of a group of parameter
///
EZC3D_API Group clone() const;

//---- STREAM ----//
public:
///
Expand Down
6 changes: 6 additions & 0 deletions include/ezc3d/Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ class EZC3D_VISIBILITY ezc3d::Header {
///
EZC3D_API Header(c3d &c3d, std::fstream &file);

///
/// \brief Create a deep copy of a header
/// \return A deep copy of the header
///
EZC3D_API Header clone() const;

//---- STREAM ----//
public:
///
Expand Down
12 changes: 12 additions & 0 deletions include/ezc3d/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,26 @@ class EZC3D_VISIBILITY ezc3d::Options {

///
/// \brief Whether to ignore bad formatting when reading C3D files
/// \return Whether to ignore bad formatting when reading C3D files
///
EZC3D_API bool getIgnoreBadFormatting() const { return _ignoreBadFormatting; }

///
/// \brief Whether to keep trailing spaces when reading strings
/// \return Whether to keep trailing spaces when reading strings
///
EZC3D_API bool getKeepParametersTrailingSpaces() const {
return _keepParametersTrailingSpaces;
}

///
/// \brief Create a deep copy of the options
/// \return A deep copy of the options
///
EZC3D_API Options clone() const {
return Options(_ignoreBadFormatting, _keepParametersTrailingSpaces);
}

protected:
bool _ignoreBadFormatting; ///< Whether to ignore bad formatting when reading
///< C3D files
Expand Down
6 changes: 6 additions & 0 deletions include/ezc3d/Parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ class EZC3D_VISIBILITY ezc3d::ParametersNS::GroupNS::Parameter {
EZC3D_API Parameter(const std::string &name = "",
const std::string &description = "");

///
/// \brief Create a deep copy of a parameter
/// \return A deep copy of the parameter
///
EZC3D_API Parameter clone() const;

//---- STREAM ----//
public:
///
Expand Down
6 changes: 6 additions & 0 deletions include/ezc3d/Parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ class EZC3D_VISIBILITY ezc3d::ParametersNS::Parameters {
///
EZC3D_API Parameters(c3d &c3d, std::fstream &file);

///
/// \brief Create a deep copy of a group holder
/// \return A deep copy of a group holder
///
EZC3D_API Parameters clone() const;

public:
///
/// \brief Test if a given group is mandatory or not
Expand Down
7 changes: 7 additions & 0 deletions include/ezc3d/Point.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ class EZC3D_VISIBILITY ezc3d::DataNS::Points3dNS::Point
EZC3D_API Point(ezc3d::c3d &c3d, std::fstream &file,
const Points3dNS::Info &pointsInfo, int pointIndex);

///
/// \brief Create a deep copy of a Point class
/// \param point The Point class to copy
/// \return A deep copy of the Point class
///
EZC3D_API Point clone() const;

//---- STREAM ----//
public:
///
Expand Down
7 changes: 7 additions & 0 deletions include/ezc3d/Points.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ class EZC3D_VISIBILITY ezc3d::DataNS::Points3dNS::Points {
EZC3D_API Points(ezc3d::c3d &c3d, std::fstream &file,
const Points3dNS::Info &info);

///
/// \brief Create a deep copy of a Points class
/// \param points The Points class to copy
/// \return A deep copy of the Points class
///
EZC3D_API Points clone() const;

//---- STREAM ----//
public:
///
Expand Down
6 changes: 6 additions & 0 deletions include/ezc3d/Rotation.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ class EZC3D_VISIBILITY ezc3d::DataNS::RotationNS::Rotation
///
EZC3D_API Rotation(const ezc3d::DataNS::RotationNS::Rotation &rotation);

///
/// \brief Create a deep copy of a Rotation
/// \return A deep copy of the Rotation
///
EZC3D_API Rotation clone() const;

//---- STREAM ----//
public:
///
Expand Down
6 changes: 6 additions & 0 deletions include/ezc3d/Rotations.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ class EZC3D_VISIBILITY ezc3d::DataNS::RotationNS::Rotations {
EZC3D_API Rotations(ezc3d::c3d &c3d, std::fstream &file,
const RotationNS::Info &info);

///
/// \brief Create a deep copy of a Rotations
/// \return A deep copy of the Rotations
///
EZC3D_API Rotations clone() const;

//---- STREAM ----//
public:
///
Expand Down
7 changes: 7 additions & 0 deletions include/ezc3d/RotationsSubframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ class EZC3D_VISIBILITY ezc3d::DataNS::RotationNS::SubFrame {
EZC3D_API SubFrame(ezc3d::c3d &c3d, std::fstream &file,
const RotationNS::Info &info);

///
/// \brief Create a deep copy of a SubFrame
/// \param subframe The SubFrame to copy
/// \return A deep copy of the SubFrame
///
EZC3D_API SubFrame clone() const;

//---- STREAM ----//
public:
///
Expand Down
6 changes: 6 additions & 0 deletions include/ezc3d/ezc3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ class EZC3D_VISIBILITY ezc3d::c3d {
EZC3D_API c3d(const std::string &filePath,
const Options &options = Options());

///
/// \brief Create a deep copy of a C3D
/// \return A deep copy of the C3D
///
EZC3D_API c3d clone() const;

//---- STREAM ----//
public:
///
Expand Down
8 changes: 8 additions & 0 deletions src/Analogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ ezc3d::DataNS::AnalogsNS::Analogs::Analogs(ezc3d::c3d &c3d, std::fstream &file,
}
}

ezc3d::DataNS::AnalogsNS::Analogs
ezc3d::DataNS::AnalogsNS::Analogs::clone() const {
Analogs copy;
for (const auto &subframe : _subframe)
copy._subframe.push_back(subframe.clone());
return copy;
}

void ezc3d::DataNS::AnalogsNS::Analogs::print() const {
for (size_t i = 0; i < nbSubframes(); ++i) {
std::cout << "Subframe = " << i << "\n";
Expand Down
8 changes: 8 additions & 0 deletions src/AnalogsSubframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ ezc3d::DataNS::AnalogsNS::SubFrame::SubFrame(
}
}

ezc3d::DataNS::AnalogsNS::SubFrame
ezc3d::DataNS::AnalogsNS::SubFrame::clone() const {
SubFrame copy;
for (const auto &channel : _channels)
copy._channels.push_back(channel.clone());
return copy;
}

void ezc3d::DataNS::AnalogsNS::SubFrame::print() const {
for (size_t i = 0; i < nbChannels(); ++i) {
channel(i).print();
Expand Down
5 changes: 5 additions & 0 deletions src/Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ ezc3d::DataNS::AnalogsNS::Channel::Channel(
info.scaleFactors()[channelIndex] * info.generalFactor());
}

ezc3d::DataNS::AnalogsNS::Channel
ezc3d::DataNS::AnalogsNS::Channel::clone() const {
return Channel(*this);
}

void ezc3d::DataNS::AnalogsNS::Channel::print() const {
std::cout << "Analog = " << data() << "\n";
}
Expand Down
7 changes: 7 additions & 0 deletions src/Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ ezc3d::DataNS::Data::Data(ezc3d::c3d &c3d, std::fstream &file) {
}
}

ezc3d::DataNS::Data ezc3d::DataNS::Data::clone() const {
Data copy;
for (const auto &frame : _frames)
copy._frames.push_back(frame.clone());
return copy;
}

void ezc3d::DataNS::Data::print() const {
for (size_t i = 0; i < nbFrames(); ++i) {
std::cout << "Frame " << i << "\n";
Expand Down
11 changes: 11 additions & 0 deletions src/Frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ ezc3d::DataNS::Frame::Frame() {
_rotations = std::make_shared<ezc3d::DataNS::RotationNS::Rotations>();
}

ezc3d::DataNS::Frame ezc3d::DataNS::Frame::clone() const {
Frame copy;
copy._points =
std::make_shared<ezc3d::DataNS::Points3dNS::Points>(_points->clone());
copy._analogs =
std::make_shared<ezc3d::DataNS::AnalogsNS::Analogs>(_analogs->clone());
copy._rotations = std::make_shared<ezc3d::DataNS::RotationNS::Rotations>(
_rotations->clone());
return copy;
}

void ezc3d::DataNS::Frame::print() const {
points().print();
analogs().print();
Expand Down
9 changes: 9 additions & 0 deletions src/Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ void ezc3d::ParametersNS::GroupNS::Group::print() const {
}
}

ezc3d::ParametersNS::GroupNS::Group
ezc3d::ParametersNS::GroupNS::Group::clone() const {
Group copy(_name, _description);
copy._isLocked = _isLocked;
for (const auto &param : _parameters)
copy._parameters.push_back(param.clone());
return copy;
}

void ezc3d::ParametersNS::GroupNS::Group::write(
const WriteOptions &writeOptions, std::fstream &f, int groupIdx,
ezc3d::DataStartInfo &dataStartPositionToFill) const {
Expand Down
32 changes: 32 additions & 0 deletions src/Header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,38 @@ ezc3d::Header::Header(ezc3d::c3d &c3d, std::fstream &file)
read(c3d, file);
}

ezc3d::Header ezc3d::Header::clone() const {
Header copy;
copy._nbOfZerosBeforeHeader = _nbOfZerosBeforeHeader;
copy._parametersAddress = _parametersAddress;
copy._checksum = _checksum;
copy._nb3dPoints = _nb3dPoints;
copy._nbAnalogsMeasurement = _nbAnalogsMeasurement;
copy._hasRotationalData = _hasRotationalData;
copy._firstFrame = _firstFrame;
copy._lastFrame = _lastFrame;
copy._nbMaxInterpGap = _nbMaxInterpGap;
copy._scaleFactor = _scaleFactor;
copy._dataStart = _dataStart;
copy._nbAnalogByFrame = _nbAnalogByFrame;
copy._frameRate = _frameRate;
copy._emptyBlock1 = _emptyBlock1;
copy._emptyBlock2 = _emptyBlock2;
copy._emptyBlock3 = _emptyBlock3;
copy._emptyBlock4 = _emptyBlock4;
copy._keyLabelPresent = _keyLabelPresent;
copy._firstBlockKeyLabel = _firstBlockKeyLabel;
copy._fourCharPresent = _fourCharPresent;
copy._nbEvents = _nbEvents;
for (size_t i = 0; i < _eventsTime.size(); ++i)
copy._eventsTime[i] = _eventsTime[i];
for (size_t i = 0; i < _eventsDisplay.size(); ++i)
copy._eventsDisplay[i] = _eventsDisplay[i];
for (size_t i = 0; i < _eventsLabel.size(); ++i)
copy._eventsLabel[i] = _eventsLabel[i];
return copy;
}

void ezc3d::Header::print() const {
std::cout << "HEADER" << "\n";
std::cout << "nb3dPoints = " << nb3dPoints() << "\n";
Expand Down
13 changes: 13 additions & 0 deletions src/Parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ ezc3d::ParametersNS::GroupNS::Parameter::Parameter(
: _name(name), _description(description), _isLocked(false),
_data_type(ezc3d::DATA_TYPE::NO_DATA_TYPE), _isEmpty(true) {}

ezc3d::ParametersNS::GroupNS::Parameter
ezc3d::ParametersNS::GroupNS::Parameter::clone() const {
Parameter copy(_name, _description);
copy._isLocked = _isLocked;
copy._data_type = _data_type;
copy._dimension = _dimension;
copy._isEmpty = _isEmpty;
copy._param_data_int = _param_data_int;
copy._param_data_double = _param_data_double;
copy._param_data_string = _param_data_string;
return copy;
}

void ezc3d::ParametersNS::GroupNS::Parameter::print() const {
std::cout << "parameterName = " << name() << "\n";
std::cout << "isLocked = " << isLocked() << "\n";
Expand Down
15 changes: 15 additions & 0 deletions src/Parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,21 @@ ezc3d::ParametersNS::Parameters::Parameters(ezc3d::c3d &c3d, std::fstream &file)
setMandatoryParameters();
}

ezc3d::ParametersNS::Parameters ezc3d::ParametersNS::Parameters::clone() const {
Parameters copy;
copy._parametersStart = _parametersStart;
copy._checksum = _checksum;
copy._nbParamBlock = _nbParamBlock;
copy._processorType = _processorType;

// Remove the mandatory groups that are automatically added by the constructor
copy._groups.clear();
for (const auto &grp : _groups) {
copy._groups.push_back(grp.clone());
}
return copy;
}

bool ezc3d::ParametersNS::Parameters::isMandatory(
const std::string &groupName) {
if (!groupName.compare("POINT") || !groupName.compare("ANALOG") ||
Expand Down
Loading
Loading