Skip to content

Commit

Permalink
changed fit_file to fit_parser and all structure around
Browse files Browse the repository at this point in the history
  • Loading branch information
neri14 committed Aug 7, 2024
1 parent 4c7f32d commit 810e6ac
Show file tree
Hide file tree
Showing 18 changed files with 11,883 additions and 156 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"cinttypes": "cpp",
"typeinfo": "cpp",
"valarray": "cpp",
"variant": "cpp"
"variant": "cpp",
"stdfloat": "cpp"
}
}
12 changes: 6 additions & 6 deletions src/telemetry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ cmake_minimum_required(VERSION 3.20.0)

target_sources(vgraph_lib
PRIVATE
file.cpp
fit_file.cpp
track.cpp
fit_parser.cpp
PUBLIC
file.h
fit_file.h
track.h
datapoint.h
enum_field.h
fit_parser.h
parser.h
value.h
)
19 changes: 19 additions & 0 deletions src/telemetry/datapoint.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef DATAPOINT_H
#define DATAPOINT_H

#include "enum_field.h"
#include "value.h"

#include <map>
#include <vector>

namespace vgraph {
namespace telemetry {

using datapoint = std::map<EField, value>;
using datapoint_sequence = std::vector<datapoint>;

} // namespace telemetry
} // namespace vgraph

#endif // DATAPOINT_H
31 changes: 31 additions & 0 deletions src/telemetry/enum_field.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef ENUM_FIELD_H
#define ENUM_FIELD_H

namespace vgraph {
namespace telemetry {

enum class EField
{
Timestamp,
Latitude,
Longitude,
Altitude,
Temperature,
Distance,
Speed,
Cadence,
Power,
LeftPedalSmoothness,
RightPedalSmoothness,
LeftTorqueEffectiveness,
RightTorqueEffectiveness,
RespirationRate,
HeartRate,
Grit,
Flow,
};

} // namespace telemetry
} // namespace vgraph

#endif // ENUM_FIELD_H
19 changes: 0 additions & 19 deletions src/telemetry/file.cpp

This file was deleted.

29 changes: 0 additions & 29 deletions src/telemetry/file.h

This file was deleted.

18 changes: 0 additions & 18 deletions src/telemetry/fit_file.cpp

This file was deleted.

21 changes: 0 additions & 21 deletions src/telemetry/fit_file.h

This file was deleted.

13 changes: 13 additions & 0 deletions src/telemetry/fit_parser.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "fit_parser.h"

namespace vgraph {
namespace telemetry {

std::shared_ptr<datapoint_sequence> fit_parser::parse(const std::string& path)
{
//FIXME to be implemented
return nullptr;
}

} // namespace telemetry
} // namespace vgraph
20 changes: 20 additions & 0 deletions src/telemetry/fit_parser.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef FIT_PARSER_H
#define FIT_PARSER_H

#include "parser.h"

namespace vgraph {
namespace telemetry {

class fit_parser : public parser {
public:
fit_parser() = default;
~fit_parser() = default;

std::shared_ptr<datapoint_sequence> parse(const std::string& path) override;
};

} // namespace telemetry
} // namespace vgraph

#endif // FIT_PARSER_H
23 changes: 23 additions & 0 deletions src/telemetry/parser.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef FILE_H
#define FILE_H

#include "datapoint.h"

#include <string>
#include <memory>

namespace vgraph {
namespace telemetry {

class parser {
public:
parser() = default;
~parser() = default;

virtual std::shared_ptr<datapoint_sequence> parse(const std::string& path) = 0;
};

} // namespace telemetry
} // namespace vgraph

#endif // FILE_H
Empty file removed src/telemetry/track.cpp
Empty file.
16 changes: 0 additions & 16 deletions src/telemetry/track.h

This file was deleted.

17 changes: 17 additions & 0 deletions src/telemetry/value.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef VALUE_H
#define VALUE_H

namespace vgraph {
namespace telemetry {

class value {
public:
value() = default;
~value() = default;
};
//TODO to be implemented, templated for different types of values

} // namespace telemetry
} // namespace vgraph

#endif // VALUE_H
2 changes: 1 addition & 1 deletion test/telemetry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ cmake_minimum_required(VERSION 3.20.0)

target_sources(vgraph_test
PRIVATE
fit_file_test.cpp
fit_parser_test.cpp
)
45 changes: 0 additions & 45 deletions test/telemetry/fit_file_test.cpp

This file was deleted.

49 changes: 49 additions & 0 deletions test/telemetry/fit_parser_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include <gtest/gtest.h>
#include "telemetry/fit_parser.h"

#include "testutils/testdata.h"

namespace vgraph {
namespace telemetry {
namespace consts {
const std::string fitfile_path = std::string(TESTDATA_DIR) + "/test.fit";
const std::string gpxfile_path = std::string(TESTDATA_DIR) + "/test.gpx";
const std::string incorrect_path = "some/incorrect/path/to/file.fit";
} // namespace consts

class fit_parser_test : public ::testing::Test {
protected:
void SetUp() override
{
uut = std::make_shared<fit_parser>();
}

void TearDown() override
{
uut.reset();
}

std::shared_ptr<fit_parser> uut;
};

TEST_F(fit_parser_test, parse_incorrect_path_returns_nullptr)
{
ASSERT_EQ(nullptr, uut->parse(consts::incorrect_path));
}

TEST_F(fit_parser_test, parse_wrong_format_returns_nullptr)
{
ASSERT_EQ(nullptr, uut->parse(consts::gpxfile_path));
}

#if 0
//FIXME to be implemented
TEST_F(fit_parser_test, parse_fit_file)
{
auto retval = uut->parse(consts::fitfile_path);
ASSERT_NE(nullptr, retval);
}
#endif

} // namespace telemetry
} // namespace vgraph
Loading

0 comments on commit 810e6ac

Please sign in to comment.