-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change pointer to shared_ptr #671
Merged
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
2808dc5
change point to uniq/shared ptr
bam241 a2d6f24
turned MBI into a unique_ptr
bam241 c5a954b
firace add c++ 11
bam241 b93dc9b
no need to force it
bam241 ab729dc
switching from unique to shared
bam241 d483256
forcing c++11
bam241 9d955aa
Add indent
bam241 f31eb12
removing it ?
bam241 2f17c8c
revseting the DAMC_macro
bam241 967353b
empty commit
bam241 67ffa6c
foircing back c++11
bam241 b78c085
add c++11 in test
bam241 e415a8f
convert from pointer to shared_ptr...
bam241 c147bd0
revert to std c++11 cmake setup
bam241 70de322
revert to force c++11
bam241 02c2a98
readd previous option
bam241 8332b18
and now ?
bam241 b4b3029
this is clean
bam241 2c48814
adding news
bam241 51a5048
Update src/dagmc/DagMC.cpp
bam241 4142a7f
Apply suggestions from code review
bam241 d9548da
Apply suggestions from code review
bam241 d559e51
add a deprecated constructor
bam241 dee0d47
vifx news name
bam241 5339237
adding new getter for share_ptr, and deprecate old ones
bam241 73b5eaf
changed test to shape_ptr
bam241 e5204af
change raw pointer for all shared_ptr in dagmc test
bam241 8e9a2bd
fixing style
bam241 075cec7
remove unnecessary includes
bam241 5715833
update news
bam241 2dd8c83
Update src/dagmc/DagMC.cpp
bam241 ff99edc
do not return shared_ptr anymore
bam241 407c83d
change to unique ptr
bam241 cb79661
attempt to fix unique_ptr
bam241 53f5110
thx @pshriwise for solving that one !
bam241 59dbae4
now return a shared_ptre for GTT and allows to retrieve MBI shared_ptr
bam241 96e9aca
set MBI_shared_ptr ass a nullptr when MBI passed as raw pointer
bam241 24317b0
return the correct MBI version
bam241 c7e7a8c
reorder incldues, add runtime_error when trying to return MBI as a sh…
bam241 3088944
update news details
bam241 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
**Added:** None | ||
|
||
**Changed:** | ||
- DagMC: updated pointer management to RAII ("Resource Allocation Is | ||
Initialization") technique: | ||
- MBI is now a shared_ptr unless passed as a raw pointer in the DagMC | ||
constructor (can be returned as a shared_ptr if not provided as a raw | ||
pointer) | ||
- GTT is now a shared_ptr, and can only be returned as such | ||
- GQT is now a uniq_ptr, (and can't be return - not change there) | ||
- DagMC tests: | ||
- DagMC instance is now a shared_ptr | ||
- when used MBI instance is now a shared_ptr | ||
|
||
**Deprecated:** | ||
- DagMC: Deprecated constructor using a raw pointer for the MBI instance, | ||
prefered way uses shared_ptr for MBI instance. | ||
|
||
**Removed:** None | ||
|
||
**Fixed:** None | ||
|
||
**Security:** None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,106 +29,90 @@ TEST_F(DagmcSimpleTest, dagmc_load_file) { | |
TEST_F(DagmcSimpleTest, dagmc_load_file_dagmc) { | ||
/* 1 - Test with external moab, load file in DAGMC*/ | ||
// make new moab core | ||
Core* mbi = new moab::Core(); | ||
std::shared_ptr<Interface> mbi = std::make_shared<Core>(); | ||
// make new dagmc into that moab | ||
DagMC* dagmc = new moab::DagMC(mbi); | ||
std::shared_ptr<DagMC> dagmc = std::make_shared<DagMC>(mbi); | ||
|
||
ErrorCode rval; | ||
|
||
// load a file | ||
rval = dagmc->load_file(input_file); | ||
EXPECT_EQ(rval, MB_SUCCESS); | ||
|
||
// delete dagmc | ||
delete dagmc; | ||
delete mbi; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎉 |
||
} | ||
|
||
TEST_F(DagmcSimpleTest, dagmc_load_file_dagmc_via_moab) { | ||
/* 2 - Test with external moab, load file in MOAB*/ | ||
// load the file into moab rather than dagmc | ||
ErrorCode rval; | ||
|
||
moab::Core* mbi = new moab::Core(); | ||
std::shared_ptr<Interface> mbi = std::make_shared<Core>(); | ||
rval = mbi->load_file(input_file); | ||
EXPECT_EQ(rval, MB_SUCCESS); | ||
moab::DagMC* dagmc = new moab::DagMC(mbi); | ||
std::shared_ptr<DagMC> dagmc = std::make_shared<DagMC>(mbi); | ||
rval = dagmc->load_existing_contents(); | ||
EXPECT_EQ(rval, MB_SUCCESS); | ||
|
||
// delete dagmc; | ||
delete dagmc; | ||
delete mbi; | ||
} | ||
|
||
TEST_F(DagmcSimpleTest, dagmc_load_file_dagmc_internal) { | ||
/* 3 - Test with internal moab, load file in DAG*/ | ||
// make new dagmc into that moab | ||
ErrorCode rval; | ||
|
||
moab::DagMC* dagmc = new moab::DagMC(); | ||
std::shared_ptr<DagMC> dagmc = std::make_shared<DagMC>(); | ||
// load a file | ||
rval = dagmc->load_file(input_file); | ||
EXPECT_EQ(rval, MB_SUCCESS); | ||
delete dagmc; | ||
} | ||
|
||
TEST_F(DagmcSimpleTest, dagmc_load_file_dagmc_build_obb) { | ||
/* 1 - Test with external moab, load file in DAGMC*/ | ||
// make new moab core | ||
ErrorCode rval; | ||
|
||
moab::Core* mbi = new moab::Core(); | ||
std::shared_ptr<Interface> mbi = std::make_shared<Core>(); | ||
// make new dagmc into that moab | ||
DagMC* dagmc = new moab::DagMC(mbi); | ||
std::shared_ptr<DagMC> dagmc = std::make_shared<DagMC>(mbi); | ||
|
||
// load a file | ||
rval = dagmc->load_file(input_file); | ||
EXPECT_EQ(rval, MB_SUCCESS); | ||
rval = dagmc->init_OBBTree(); | ||
EXPECT_EQ(rval, MB_SUCCESS); | ||
// delete dagmc | ||
delete dagmc; | ||
delete mbi; | ||
} | ||
|
||
TEST_F(DagmcSimpleTest, dagmc_load_file_dagmc_via_moab_build_obb) { | ||
/* 2 - Test with external moab, load file in MOAB*/ | ||
// load the file into moab rather than dagmc | ||
ErrorCode rval; | ||
|
||
moab::Core* mbi = new moab::Core(); | ||
std::shared_ptr<Interface> mbi = std::make_shared<Core>(); | ||
rval = mbi->load_file(input_file); | ||
EXPECT_EQ(rval, MB_SUCCESS); | ||
moab::DagMC* dagmc = new moab::DagMC(mbi); | ||
std::shared_ptr<DagMC> dagmc = std::make_shared<DagMC>(mbi); | ||
rval = dagmc->load_existing_contents(); | ||
EXPECT_EQ(rval, MB_SUCCESS); | ||
rval = dagmc->init_OBBTree(); | ||
EXPECT_EQ(rval, MB_SUCCESS); | ||
|
||
// delete dagmc; | ||
delete dagmc; | ||
delete mbi; | ||
} | ||
|
||
TEST_F(DagmcSimpleTest, dagmc_load_file_dagmc_internal_build_obb) { | ||
/* 3 - Test with internal moab, load file in DAG*/ | ||
// make new dagmc into that moab | ||
ErrorCode rval; | ||
|
||
moab::DagMC* dagmc = new moab::DagMC(); | ||
std::shared_ptr<DagMC> dagmc = std::make_shared<DagMC>(); | ||
// load a file | ||
rval = dagmc->load_file(input_file); | ||
EXPECT_EQ(rval, MB_SUCCESS); | ||
rval = dagmc->init_OBBTree(); | ||
EXPECT_EQ(rval, MB_SUCCESS); | ||
delete dagmc; | ||
} | ||
|
||
TEST_F(DagmcSimpleTest, dagmc_test_obb_retreval) { | ||
// make new dagmc | ||
std::cout << "test_obb_retreval" << std::endl; | ||
|
||
DagMC* dagmc = new moab::DagMC(); | ||
std::shared_ptr<DagMC> dagmc = std::make_shared<DagMC>(); | ||
|
||
ErrorCode rval; | ||
// load a file | ||
|
@@ -140,18 +124,14 @@ TEST_F(DagmcSimpleTest, dagmc_test_obb_retreval) { | |
// write the file | ||
rval = dagmc->write_mesh("fcad", 4); | ||
|
||
// now remove the dagmc instance a | ||
delete dagmc; | ||
|
||
dagmc = new moab::DagMC(); | ||
dagmc.reset(new DagMC()); | ||
rval = dagmc->load_file("fcad"); | ||
EXPECT_EQ(rval, MB_SUCCESS); | ||
rval = dagmc->init_OBBTree(); | ||
EXPECT_EQ(rval, MB_SUCCESS); | ||
|
||
// delete the fcad file | ||
remove("fcad"); | ||
delete dagmc; | ||
} | ||
|
||
TEST_F(DagmcSimpleTest, dagmc_build_obb) { | ||
|
@@ -180,7 +160,7 @@ TEST_F(DagmcSimpleTest, dagmc_test_obb_retreval_rayfire) { | |
// make new dagmc | ||
std::cout << "test_obb_retreval and ray_fire" << std::endl; | ||
|
||
DagMC* dagmc = new moab::DagMC(); | ||
std::shared_ptr<DagMC> dagmc = std::make_shared<DagMC>(); | ||
|
||
ErrorCode rval; | ||
// load a file | ||
|
@@ -192,11 +172,8 @@ TEST_F(DagmcSimpleTest, dagmc_test_obb_retreval_rayfire) { | |
// write the file | ||
rval = dagmc->write_mesh("fcad", 4); | ||
|
||
// now remove the dagmc instance | ||
delete dagmc; | ||
|
||
// now create new DAGMC | ||
dagmc = new moab::DagMC(); | ||
dagmc.reset(new DagMC()); | ||
rval = dagmc->load_file("fcad"); | ||
EXPECT_EQ(rval, MB_SUCCESS); | ||
rval = dagmc->init_OBBTree(); | ||
|
@@ -220,7 +197,6 @@ TEST_F(DagmcSimpleTest, dagmc_test_obb_retreval_rayfire) { | |
rval = DAG->ray_fire(vol_h, xyz, dir, next_surf, next_surf_dist); | ||
EXPECT_EQ(rval, MB_SUCCESS); | ||
EXPECT_NEAR(expect_next_surf_dist, next_surf_dist, eps); | ||
delete dagmc; | ||
} | ||
|
||
TEST_F(DagmcSimpleTest, dagmc_rayfire) { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a
runtime_error
when trying to return theMBI
instance as ashared_ptr
when it has been provided as a direct pointer. (It has been implemented in the Header, as it is fairly simple, I can move it to thecpp
file if you prefer)