Skip to content

Commit f1e0a65

Browse files
committed
fully commit to shared pointers only
1 parent a033fd1 commit f1e0a65

File tree

7 files changed

+90
-178
lines changed

7 files changed

+90
-178
lines changed

include/fdp/objects/api_object.hxx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ namespace FDP {
2020

2121
public:
2222

23-
typedef std::unique_ptr< ApiObject > uptr;
2423
typedef std::shared_ptr< ApiObject > sptr;
2524

26-
static uptr from_json( const Json::Value& j );
25+
static sptr from_json( const Json::Value& j );
2726

2827
//static copy( const ApiObject& src );
2928

@@ -33,7 +32,7 @@ namespace FDP {
3332
* @param uri uri of the api object e.g. http://127.0.0.1/object/1
3433
*/
3534

36-
static ApiObject::uptr construct( void );
35+
static ApiObject::sptr construct( void );
3736

3837

3938
int add( const std::string& key, int value );

include/fdp/objects/config.hxx

Lines changed: 27 additions & 23 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_;
@@ -41,24 +40,24 @@ namespace FDP {
4140
std::string token_;
4241
API::sptr api_;
4342

44-
ApiObject::uptr user_;
45-
ApiObject::uptr author_;
43+
ApiObject::sptr user_;
44+
ApiObject::sptr author_;
4645

47-
ApiObject::uptr config_storage_root_;
48-
ApiObject::uptr config_storage_location_;
49-
ApiObject::uptr config_file_type_;
50-
ApiObject::uptr 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-
ApiObject::uptr script_storage_root_;
53-
ApiObject::uptr script_storage_location_;
54-
ApiObject::uptr script_file_type_;
55-
ApiObject::uptr 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-
ApiObject::uptr code_repo_storage_root_;
58-
ApiObject::uptr code_repo_storage_location_;
59-
ApiObject::uptr 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-
ApiObject::uptr code_run_;
60+
ApiObject::sptr code_run_;
6261

6362
std::map<std::string, IOObject> writes_;
6463
std::map<std::string, IOObject> reads_;
@@ -73,11 +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-
typedef std::unique_ptr< Config > uptr;
79-
80-
8175
/**
8276
* @brief Construct a new Config object
8377
*
@@ -87,9 +81,19 @@ namespace FDP {
8781
* @param api_location whether or not the api is local
8882
*/
8983
Config(const ghc::filesystem::path &config_file_path,
90-
const ghc::filesystem::path &script_file_path,
91-
const std::string &token,
92-
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+
9397

9498
/**
9599
* @brief Destroy the Config object

src/fdp.cxx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace FDP {
3030
class DataPipeline::impl {
3131

3232
private:
33-
Config::uptr config_;
33+
Config::sptr config_;
3434

3535
ghc::filesystem::path config_file_path_() const {return config_->get_config_file_path();}
3636
ghc::filesystem::path script_file_path_() const {return config_->get_script_file_path();}
@@ -117,8 +117,7 @@ DataPipeline::impl::impl(const ghc::filesystem::path &config_file_path,
117117
spdlog::level::level_enum log_level,
118118
RESTAPI api_location)
119119
{
120-
Config::uptr configPtr(new Config(config_file_path, script_file_path, token, api_location));
121-
config_ = std::move(configPtr);
120+
this->config_ = Config::construct(config_file_path, script_file_path, token, api_location);
122121

123122
const std::string api_root_ = config_->get_api_url();
124123

src/objects/api_object.cxx

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,20 @@ namespace FDP {
66
{
77
}
88

9-
ApiObject::uptr ApiObject::from_json( const Json::Value& j )
9+
ApiObject::sptr ApiObject::from_json( const Json::Value& j )
1010
{
11-
// ApiObject::uptr pobj = std::unique_ptr< ApiObject >( new ApiObject( j ) );
12-
13-
ApiObject::uptr pobj = ApiObject::construct();
11+
ApiObject::sptr pobj = ApiObject::construct();
1412
pobj->obj_ = j;
1513

1614
return pobj;
1715
}
1816

19-
ApiObject::uptr ApiObject::construct(void)
17+
ApiObject::sptr ApiObject::construct(void)
2018
{
21-
ApiObject::uptr pobj = std::unique_ptr< ApiObject >( new ApiObject() );
19+
ApiObject::sptr pobj = std::shared_ptr< ApiObject >( new ApiObject() );
2220
return pobj;
2321
}
24-
#if 0
25-
ApiObject::uptr ApiObject::copy( const ApiObject& src )
26-
{
27-
ApiObject::uptr pobj = std::unique_ptr< ApiObject >( new ApiObject() );
2822

29-
pobj->obj_.copy( src.obj_ );
30-
return obj;
31-
}
32-
#endif
3323
int ApiObject::add( const std::string& key, int value )
3424
{
3525
this->obj_[ key ] = value;

0 commit comments

Comments
 (0)