Skip to content

Commit 6841973

Browse files
committed
Merge remote-tracking branch 'origin/main' into ryanjfield-dev
2 parents 6007372 + 1592b2c commit 6841973

File tree

16 files changed

+524
-378
lines changed

16 files changed

+524
-378
lines changed

include/fdp/fdp.hxx

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
#include "fdp/registry/datapipeline.hxx"
1+
#ifndef __FDP__
2+
#define __FDP__
3+
4+
#include "spdlog/spdlog.h"
5+
#include <ghc/filesystem.hpp>
6+
7+
//#include "fdp/registry/datapipeline.hxx"
28

39
namespace FDP {
410
/**
511
* @brief DataPipeline Class:
612
* A PIMPL Class for interacting the the FAIR Data Pipeline
713
*
814
*/
9-
class DataPipeline {
10-
public:
15+
class DataPipeline {
16+
17+
public:
1118
/**
1219
* @brief Construct a new Data Pipeline (PIMPL)
1320
*
@@ -16,28 +23,23 @@ public:
1623
* @param token
1724
* @param log_level
1825
*/
19-
explicit DataPipeline(
20-
const std::string &config_file_path,
21-
const std::string &script_file_path,
22-
std::string token = "",
23-
spdlog::level::level_enum log_level = spdlog::level::info)
24-
: pimpl_(std::make_shared<DataPipelineImpl_>(ghc::filesystem::path(config_file_path), ghc::filesystem::path(script_file_path), token,
25-
log_level)) {
26-
27-
APILogger->debug("DataPipeline: Initialising session '{0}'", Pimpl()->get_code_run_uuid());
28-
}
26+
explicit DataPipeline(
27+
const std::string &config_file_path,
28+
const std::string &script_file_path,
29+
std::string token = "",
30+
spdlog::level::level_enum log_level = spdlog::level::info);
2931

3032
/**
3133
* @brief Destroy the Data Pipeline object
3234
*
3335
*/
34-
~DataPipeline();
36+
~DataPipeline();
3537

36-
DataPipeline(DataPipeline &&rhs) noexcept;
37-
DataPipeline &operator=(DataPipeline &&rhs) noexcept;
38+
DataPipeline(DataPipeline &&rhs) noexcept;
39+
DataPipeline &operator=(DataPipeline &&rhs) noexcept;
3840

39-
DataPipeline(const DataPipeline &rhs);
40-
DataPipeline &operator=(const DataPipeline &rhs);
41+
DataPipeline(const DataPipeline &rhs);
42+
DataPipeline &operator=(const DataPipeline &rhs);
4143

4244
/**
4345
* @brief Return a path to a given data product
@@ -46,7 +48,7 @@ public:
4648
* @param data_product
4749
* @return ghc::filesystem::path
4850
*/
49-
ghc::filesystem::path link_read(std::string &data_product);
51+
ghc::filesystem::path link_read(std::string &data_product);
5052

5153
/**
5254
* @brief Return a path to be used for a given data product
@@ -55,20 +57,21 @@ public:
5557
* @param data_product
5658
* @return ghc::filesystem::path
5759
*/
58-
ghc::filesystem::path link_write(std::string &data_product);
60+
ghc::filesystem::path link_write(std::string &data_product);
5961

6062
/**
6163
* @brief Finalise the pipeline
6264
* Record all data products and meta data to the registry
6365
* update the code run with all appropriate meta data
6466
*
6567
*/
66-
void finalise();
68+
void finalise();
69+
70+
private:
71+
class impl;
72+
73+
std::shared_ptr< DataPipeline::impl > pimpl_;
74+
};
75+
}; // namespace FDP
6776

68-
private:
69-
const DataPipelineImpl_* Pimpl() const {return pimpl_.get();}
70-
DataPipelineImpl_* Pimpl() {return pimpl_.get();}
71-
72-
std::shared_ptr<DataPipelineImpl_> pimpl_;
73-
};
74-
}; // namespace FDP
77+
#endif

include/fdp/objects/api_object.hxx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,33 @@ namespace FDP {
1515
class ApiObject {
1616
private:
1717
Json::Value obj_;
18+
19+
ApiObject();
20+
1821
public:
19-
ApiObject() : obj_(Json::Value()){};
22+
23+
typedef std::shared_ptr< ApiObject > sptr;
24+
25+
static sptr from_json( const Json::Value& j );
26+
27+
//static copy( const ApiObject& src );
28+
2029
/**
2130
* @brief Construct a new Api Object object
2231
*
2332
* @param uri uri of the api object e.g. http://127.0.0.1/object/1
2433
*/
25-
ApiObject(Json::Value obj) : obj_(obj){}
34+
35+
static ApiObject::sptr construct( void );
36+
37+
38+
int add( const std::string& key, int value );
39+
int add( const std::string& key, float value );
40+
int add( const std::string& key, double value );
41+
int add( const std::string& key, const std::string& value );
42+
int add( const std::string& key, const ApiObject& value );
43+
44+
int remove( const std::string& key );
2645
/**
2746
* @brief Get the object id from the uri
2847
*
@@ -79,4 +98,4 @@ namespace FDP {
7998
};
8099
};
81100

82-
#endif
101+
#endif

include/fdp/objects/config.hxx

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ namespace FDP {
3030
* @brief class for interacting with confifurations
3131
*
3232
*/
33-
3433
class Config {
3534
private:
3635
const ghc::filesystem::path config_file_path_;
@@ -39,26 +38,26 @@ namespace FDP {
3938
YAML::Node config_data_;
4039
std::string api_url_;
4140
std::string token_;
42-
std::shared_ptr<API> api_;
41+
API::sptr api_;
4342

44-
std::unique_ptr<ApiObject> user_;
45-
std::unique_ptr<ApiObject> author_;
43+
ApiObject::sptr user_;
44+
ApiObject::sptr author_;
4645

47-
std::unique_ptr<ApiObject> config_storage_root_;
48-
std::unique_ptr<ApiObject> config_storage_location_;
49-
std::unique_ptr<ApiObject> config_file_type_;
50-
std::unique_ptr<ApiObject> config_obj_;
46+
ApiObject::sptr config_storage_root_;
47+
ApiObject::sptr config_storage_location_;
48+
ApiObject::sptr config_file_type_;
49+
ApiObject::sptr config_obj_;
5150

52-
std::unique_ptr<ApiObject> script_storage_root_;
53-
std::unique_ptr<ApiObject> script_storage_location_;
54-
std::unique_ptr<ApiObject> script_file_type_;
55-
std::unique_ptr<ApiObject> script_obj_;
51+
ApiObject::sptr script_storage_root_;
52+
ApiObject::sptr script_storage_location_;
53+
ApiObject::sptr script_file_type_;
54+
ApiObject::sptr script_obj_;
5655

57-
std::unique_ptr<ApiObject> code_repo_storage_root_;
58-
std::unique_ptr<ApiObject> code_repo_storage_location_;
59-
std::unique_ptr<ApiObject> code_repo_obj_;
56+
ApiObject::sptr code_repo_storage_root_;
57+
ApiObject::sptr code_repo_storage_location_;
58+
ApiObject::sptr code_repo_obj_;
6059

61-
std::unique_ptr<ApiObject> code_run_;
60+
ApiObject::sptr code_run_;
6261

6362
std::map<std::string, IOObject> writes_;
6463
std::map<std::string, IOObject> reads_;
@@ -73,9 +72,6 @@ namespace FDP {
7372

7473
void initialise(RESTAPI api_location);
7574
void validate_config(ghc::filesystem::path yaml_path, RESTAPI api_location);
76-
77-
public:
78-
7975
/**
8076
* @brief Construct a new Config object
8177
*
@@ -85,9 +81,19 @@ namespace FDP {
8581
* @param api_location whether or not the api is local
8682
*/
8783
Config(const ghc::filesystem::path &config_file_path,
88-
const ghc::filesystem::path &script_file_path,
89-
const std::string &token,
90-
RESTAPI api_location);
84+
const ghc::filesystem::path &script_file_path,
85+
const std::string &token,
86+
RESTAPI api_location);
87+
88+
89+
public:
90+
typedef std::shared_ptr< Config > sptr;
91+
92+
static Config::sptr construct(const ghc::filesystem::path &config_file_path,
93+
const ghc::filesystem::path &script_file_path,
94+
const std::string &token,
95+
RESTAPI api_location);
96+
9197

9298
/**
9399
* @brief Destroy the Config object
@@ -257,7 +263,7 @@ namespace FDP {
257263
*
258264
* @return std::shared_ptr<API>
259265
*/
260-
std::shared_ptr<API> get_api(){return api_;}
266+
API::sptr get_api(){return api_;}
261267

262268
/**
263269
* @brief Get the rest api location (local / remote)
@@ -268,4 +274,4 @@ namespace FDP {
268274

269275
};
270276
};
271-
#endif
277+
#endif

include/fdp/objects/io_object.hxx

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ namespace FDP {
2525
std::string component_description_ = "None";
2626
bool public_ = false;
2727

28-
std::shared_ptr<ApiObject> component_obj_;
29-
std::shared_ptr<ApiObject> data_product_obj_;
28+
ApiObject::sptr component_obj_;
29+
ApiObject::sptr data_product_obj_;
3030

3131
public:
3232
/**
@@ -47,19 +47,20 @@ namespace FDP {
4747
* @param isPublic whether or not the data product should be public
4848
*/
4949
IOObject(std::string data_product,
50-
std::string use_data_product,
51-
std::string use_version,
52-
std::string use_namespace,
53-
ghc::filesystem::path path,
54-
std::string data_product_description,
55-
bool isPublic):
56-
data_product_(data_product),
57-
use_data_product_(use_data_product),
58-
use_version_(use_version),
59-
use_namespace_(use_namespace),
60-
path_(path),
61-
data_product_description_(data_product_description),
62-
public_(isPublic){};
50+
std::string use_data_product,
51+
std::string use_version,
52+
std::string use_namespace,
53+
ghc::filesystem::path path,
54+
std::string data_product_description,
55+
bool isPublic)
56+
:
57+
data_product_(data_product),
58+
use_data_product_(use_data_product),
59+
use_version_(use_version),
60+
use_namespace_(use_namespace),
61+
path_(path),
62+
data_product_description_(data_product_description),
63+
public_(isPublic){};
6364

6465
/**
6566
* @brief Construct a new IOObject object
@@ -79,14 +80,15 @@ namespace FDP {
7980
std::string use_namespace,
8081
ghc::filesystem::path path,
8182
ApiObject &component_obj,
82-
ApiObject &data_product_obj):
83-
data_product_(data_product),
84-
use_data_product_(use_data_product),
85-
use_version_(use_version),
86-
use_namespace_(use_namespace),
87-
path_(path),
88-
component_obj_(std::make_shared<ApiObject>(component_obj)),
89-
data_product_obj_(std::make_shared<ApiObject>(data_product_obj)){};
83+
ApiObject &data_product_obj)
84+
:
85+
data_product_(data_product),
86+
use_data_product_(use_data_product),
87+
use_version_(use_version),
88+
use_namespace_(use_namespace),
89+
path_(path),
90+
component_obj_(std::make_shared<ApiObject>(component_obj)),
91+
data_product_obj_(std::make_shared<ApiObject>(data_product_obj)){};
9092

9193
/**
9294
* @brief Get the data product as a string
@@ -157,21 +159,22 @@ namespace FDP {
157159
*
158160
* @return std::shared_ptr<ApiObject>
159161
*/
160-
std::shared_ptr<ApiObject> get_component_object() {return component_obj_;}
162+
ApiObject::sptr get_component_object() {return component_obj_;}
163+
161164

162165
/**
163166
* @brief Get the data product object object
164167
*
165168
* @return std::shared_ptr<ApiObject>
166169
*/
167-
std::shared_ptr<ApiObject> get_data_product_object() {return data_product_obj_;}
170+
ApiObject::sptr get_data_product_object() {return data_product_obj_;}
168171

169172
/**
170173
* @brief Set the component object object
171174
*
172175
* @param component_obj
173176
*/
174-
void set_component_object(ApiObject &component_obj){component_obj_ = std::make_shared<ApiObject>(component_obj);}
177+
void set_component_object(ApiObject& component_obj){component_obj_ = std::make_shared<ApiObject>(component_obj);}
175178

176179
/**
177180
* @brief Set the data product object object
@@ -182,4 +185,4 @@ namespace FDP {
182185
};
183186
};
184187

185-
#endif
188+
#endif

include/fdp/registry/api.hxx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ size_t write_func_(void *ptr, size_t size, size_t nmemb, std::string *data);
6262
*****************************************************************************/
6363
class API {
6464
public:
65+
typedef std::shared_ptr< API > sptr;
66+
6567
/*! *************************************************************************
6668
* @brief construct an API object using the given URL as the root
6769
* @author K. Zarebski (UKAEA)
@@ -183,4 +185,4 @@ std::string url_encode(std::string url);
183185

184186
}; // namespace FDP
185187

186-
#endif
188+
#endif

0 commit comments

Comments
 (0)