Skip to content
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

Proposal for SiteSet simplification. #404

Open
wants to merge 1 commit into
base: v3
Choose a base branch
from

Conversation

JanReimers
Copy link
Contributor

-The design need the behaviour of an array of polymorphic objects. If you try to do this using any pointers/new/delete then you fighting the language. I have also tried to do this in the past.
-In ordfer to work with the language we must use new when creating sites, but those pointers cab be immediately deposited in a std::shared_pointer. This is a reference counted pointer that does all the memory management for us. AND we can copy them (or the whole array) at will.
-Tested for memory leaks with valgrind .. no leaks.
-Users adding new site types will have to virtually inheret from SiteBase. But I don't think they will need to directly deal with pointers. You can see and example of this in the sample/electronk.h
-I think we can set things up so that users can build arbitrary mixed site sets. again without using pointers directly.
-In the unit tests I added some examples of what can happen when writeing to file and reading back. Right now you must know what SiteSet type you are reading back other wise chaos will ensue! Again we can fix this using a factory pattern behind the scenes.
SiteSet refactoring proposal

Fix build in sample folder

-The design need the behaviour of an array of polymorphic objects. If you try to do this using any pointers/new/delete then you fighting the language.  I have also tried to do this in the past.
-In ordfer to work with the language we must use new when creating sites, but those pointers cab be immediately deposited in a std::shared_pointer<SiteBase>.  This is a reference counted pointer  that does all the memory management for us.  AND we can copy them (or the whole array) at will.
-Tested for memory leaks with valgrind .. no leaks.
-Users adding new site types will have to virtually inheret from SiteBase. But I don't think they will need to directly deal with pointers. You can see and example of this in the sample/electronk.h
-I think we can set things up so that users can build arbitrary mixed site sets. again without using pointers directly.
-In the unit tests I added some examples of what can happen when writeing to file and reading back.  Right now you must know what SiteSet type you are reading back other wise chaos will ensue!  Again we can fix this using a factory pattern behind the scenes.
SiteSet refactoring proposal

Fix build in sample folder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant