Skip to content

Commit f7f81ff

Browse files
committed
Update block generation
1 parent 444960c commit f7f81ff

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/model/Model.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,27 +60,27 @@ Model::Model() {
6060

6161
Model::~Model() {}
6262

63-
Block *Model::create_block(const std::string &block_type) {
63+
std::shared_ptr<Block> Model::create_block(const std::string &block_type) {
6464
// Get block from factory
6565
auto it = block_factory_map.find(block_type);
6666
if (it == block_factory_map.end()) {
6767
throw std::runtime_error("Invalid block type " + block_type);
6868
}
6969
std::shared_ptr<Block> block = it->second(block_count, this);
70-
return block.get();
70+
return block;
7171
}
7272

73-
int Model::add_block(Block *block, const std::string_view &name,
73+
int Model::add_block(std::shared_ptr<Block> block, const std::string_view &name,
7474
const std::vector<int> &block_param_ids, bool internal) {
7575
// Set global parameter IDs
7676
block->setup_params_(block_param_ids);
7777

7878
auto name_string = static_cast<std::string>(name);
7979

8080
if (internal) {
81-
hidden_blocks.push_back(std::shared_ptr<Block>(block));
81+
hidden_blocks.push_back(block);
8282
} else {
83-
blocks.push_back(std::shared_ptr<Block>(block));
83+
blocks.push_back(block);
8484
}
8585

8686
block_types.push_back(block->block_type);

src/model/Model.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class Model {
9999
* @param block_name The block name (defined in block_factory_map)
100100
* @return int Global ID of the block
101101
*/
102-
Block *create_block(const std::string &block_name);
102+
std::shared_ptr<Block> create_block(const std::string &block_name);
103103

104104
/**
105105
* @brief Add a block to the model (without parameters)
@@ -110,7 +110,7 @@ class Model {
110110
* @param internal Toggle whether block is internal
111111
* @return int Global ID of the block
112112
*/
113-
int add_block(Block *block, const std::string_view &name,
113+
int add_block(std::shared_ptr<Block> block, const std::string_view &name,
114114
const std::vector<int> &block_param_ids, bool internal = false);
115115

116116
/**

0 commit comments

Comments
 (0)