Skip to content

Commit 0494fa8

Browse files
committed
refactor next stages
1 parent 9771253 commit 0494fa8

28 files changed

+247
-82
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"typeindex": "cpp",
7171
"list": "cpp",
7272
"filesystem": "cpp",
73-
"shared_mutex": "cpp"
73+
"shared_mutex": "cpp",
74+
"armadillo": "cpp"
7475
}
7576
}

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ set(SOURCES
4949
src/filewriter.cpp
5050
src/graphconverter.cpp
5151
src/filesystemutils.cpp
52+
src/resourcelocation.cpp
5253
)
5354

5455
add_executable(${PROJECT_NAME} ${SOURCES})

config.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[database]
22
source=C:/Users/Kacper/Desktop/DBGRAPH/graphs/db/bin
33
ground=C:/Users/Kacper/Desktop/DBGRAPH/graphs/db/gtr
4-
target=D:/test2
4+
target=D:/test3

include/filesystemutils.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
class FilesystemUtils
1111
{
1212
public:
13-
bool create_directory(std::filesystem::path path, std::string directory_name) const;
14-
bool create_directories(std::filesystem::path path) const;
13+
static bool create_directory(std::filesystem::path path, std::string directory_name);
14+
static bool create_directories(std::filesystem::path path);
1515
};
1616

1717

include/gfile.hpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
#ifndef GFILE_H
44
#define GFILE_H
55

6+
#include "fileio.hpp"
67
#include "graphcharacteristics.hpp"
8+
#include "resourcelocation.hpp"
9+
#include <boost/algorithm/string.hpp>
710
#include <filesystem>
11+
#include <vector>
812
#include <string>
913

1014
namespace sfs = std::filesystem;
@@ -13,20 +17,23 @@ class GFile
1317
{
1418
private:
1519
sfs::path path;
20+
sfs::path target_path;
1621
GraphCharacteristics characteristics;
1722

1823
public:
19-
GFile(){}; // to delete after implementation
20-
virtual ~GFile() = default; // make this type polymorphic
24+
GFile(){};
2125
GFile(const sfs::path filepath);
26+
virtual ~GFile() = default;
2227

23-
const sfs::path relative_toward(const sfs::path base_path) const;
24-
const sfs::path absolute() const;
28+
virtual void build_target_absolute(const ResourceLocation resource) = 0;
29+
virtual std::string build_target_filename() const = 0;
2530

26-
// getters
31+
const sfs::path absolute() const;
2732
const sfs::path get_path() const;
33+
const sfs::path get_target_path() const;
34+
void set_target_path(std::filesystem::path target_path);
2835
const GraphCharacteristics get_characteristics() const;
36+
const sfs::path relative_toward(const sfs::path base_path) const;
2937
};
3038

31-
3239
#endif //GFILE_H

include/graphconverter.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "graphwriter.hpp"
1212
#include "groundreader.hpp"
1313
#include "groundwriter.hpp"
14+
#include "resourcelocation.hpp"
1415
#include "filesystemutils.hpp"
1516
#include "filereader.hpp"
1617
#include <boost/log/trivial.hpp>
@@ -23,18 +24,15 @@ class GraphConverter
2324
GReader reader;
2425
GWriter writer;
2526
FileReader config;
26-
FilesystemUtils fs_utils;
27-
std::filesystem::path source_db_uri;
28-
std::filesystem::path target_db_uri;
29-
std::filesystem::path ground_db_uri;
27+
// FilesystemUtils fs_utils;
28+
ResourceLocation resource;
3029

3130
public:
3231
GraphConverter();
3332
void preactions() const;
3433
void postactions();
3534
void convert();
3635
private:
37-
void base_procedure(std::filesystem::path path, std::function<void(std::filesystem::path path)> procedure);
3836
void create_required_directories(std::filesystem::path path) const;
3937
};
4038

include/graphreader.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55

66
#include "ireadable.hpp"
77
#include "vgraphfile.hpp"
8+
#include "vgraphfile.hpp"
89
#include <memory>
910

1011
class GraphReader : public IReadable
1112
{
1213
public:
13-
virtual GFile read(GFile &file);
14+
virtual GFile* read(GFile &file);
1415
private:
1516
unsigned short read_word(FILE* in) const;
1617
void read_graph(FILE* in, VGraphFile &file) const;

include/greader.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
class GReader
1111
{
1212
private:
13-
std::unique_ptr<IReadable> gcontext;
13+
IReadable* gcontext;
1414
public:
15-
explicit GReader(std::unique_ptr<IReadable> &&gcontext = {}) : gcontext(std::move(gcontext)){};
16-
void set_context(std::unique_ptr<IReadable> &&gcontext);
17-
GFile read(GFile &file) const;
15+
GReader(){};
16+
GReader(IReadable &gcontext);
17+
void set_context(IReadable &gcontext);
18+
GFile* read(GFile &file) const;
1819
};
1920

20-
2121
#endif //G_READER_H

include/groundfile.hpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,24 @@
44
#define GROUND_FILE_H
55

66
#include "gfile.hpp"
7+
#include "itargetable.hpp"
78
#include <map>
89

9-
class GroundFile : public GFile
10+
class GroundFile : public GFile//, public ITargetable
1011
{
1112
private:
1213
std::map<std::string, int> adjacencies;
1314

1415
public:
15-
GroundFile(const std::filesystem::path path);
16+
GroundFile() {}; // to delete after full implementation
17+
GroundFile(const std::filesystem::path path) : GFile(path) {};
18+
19+
virtual void build_target_absolute(const ResourceLocation resource) override;
20+
virtual std::string build_target_filename() const override;
21+
22+
// getters, setters
23+
const std::map<std::string, int> get_adjacencies() const;
24+
void set_adjacencies(std::map<std::string, int> adjacencies);
1625
};
1726

1827

include/groundreader.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
#define GRAOUND_READER_H
55

66
#include "ireadable.hpp"
7+
#include "groundfile.hpp"
78

89
class GroundReader : public IReadable
910
{
1011
public:
11-
virtual GFile read(GFile &file);
12+
virtual GFile* read(GFile &file);
1213
private:
1314
};
1415

0 commit comments

Comments
 (0)