Skip to content

Commit d37f14e

Browse files
committed
Update getObject to use two constructors
1 parent cd3e507 commit d37f14e

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

src/filepattern/cpp/interface/filepattern.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ FilePattern::FilePattern(const std::string& path, const std::string& filePattern
88

99
FilePatternFactory fpf = FilePatternFactory();
1010

11-
this->fp_ = std::unique_ptr<PatternObject>(fpf.getObject(path, filePattern, block_size, recursive, suppressWarnings, std::vector<std::string>{}));
11+
this->fp_ = std::unique_ptr<PatternObject>(fpf.getObject(path, filePattern, block_size, recursive, suppressWarnings));
1212

1313
if (block_size != "") {
1414
this->fp_->external = true;
@@ -22,7 +22,7 @@ FilePattern::FilePattern(const std::vector<std::string>& file_array, const std::
2222

2323
FilePatternFactory fpf = FilePatternFactory();
2424

25-
this->fp_ = std::unique_ptr<PatternObject>(fpf.getObject("", filePattern, "", recursive, suppressWarnings, file_array));
25+
this->fp_ = std::unique_ptr<PatternObject>(fpf.getObject(file_array, filePattern, suppressWarnings));
2626

2727
this->fp_->external = false;
2828

@@ -134,12 +134,12 @@ std::string FilePattern::inferPattern(const std::string& path, std::string& vari
134134

135135
// create dummy object to avoid the need for static methods in virtual class
136136
std::unique_ptr<PatternObject> fp;
137-
std::vector<std::string> empty; // TODO: implement infer pattern for a vector
137+
138138
if (block_size == "") {
139-
fp = std::unique_ptr<PatternObject>(fpf.getObject(path, "", block_size, false, true, empty));
139+
fp = std::unique_ptr<PatternObject>(fpf.getObject(path, "", block_size, false, true));
140140
} else {
141141

142-
fp = std::unique_ptr<PatternObject>(fpf.getObject(path, "", block_size, false, true, empty));
142+
fp = std::unique_ptr<PatternObject>(fpf.getObject(path, "", block_size, false, true));
143143
}
144144

145145

@@ -149,8 +149,8 @@ std::string FilePattern::inferPattern(const std::string& path, std::string& vari
149149
std::string FilePattern::inferPattern(std::vector<std::string>& vec, std::string& variables) {
150150

151151
FilePatternFactory fpf = FilePatternFactory();
152-
std::vector<std::string> empty;
153-
std::unique_ptr<PatternObject> fp = std::unique_ptr<PatternObject>(fpf.getObject(".", "dummy_pattern", "", false, true, empty));
152+
153+
std::unique_ptr<PatternObject> fp = std::unique_ptr<PatternObject>(fpf.getObject(".", "dummy_pattern", "", false, true));
154154

155155
return fp->inferPattern(vec, variables);
156156
}

src/filepattern/cpp/interface/filepattern_factory.h

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,28 @@
99
#include "../external/external_vectorpattern.hpp"
1010
#include "../util/vector_parser.hpp"
1111

12-
#ifdef WITH_PYTHON_H
13-
#include <pybind11/pybind11.h>
14-
#include <pybind11/stl.h>
15-
#include <pybind11/numpy.h>
16-
namespace py = pybind11;
17-
#endif
12+
1813
class FilePatternFactory {
1914

2015
public:
2116

2217
FilePatternFactory() {}
2318

19+
std::unique_ptr<PatternObject> getObject(
20+
const std::vector<std::string>& file_array,
21+
const std::string& file_pattern,
22+
bool suppressWarnings) {
23+
24+
return std::make_unique<ArrayPattern>(file_array, file_pattern, suppressWarnings);
25+
26+
}
27+
2428
std::unique_ptr<PatternObject> getObject(
2529
const std::string& path,
2630
const std::string& file_pattern,
2731
const std::string& block_size,
2832
bool recursive,
29-
bool suppressWarnings,
30-
const std::vector<std::string>& file_array) {
31-
32-
// check if array of strings was passed
33-
if (file_array.size() > 0) {
34-
return std::make_unique<ArrayPattern>(file_array, file_pattern, suppressWarnings);
35-
}
33+
bool suppressWarnings) {
3634

3735
if (block_size == "") {
3836
if(fs::is_regular_file(path)) {

0 commit comments

Comments
 (0)