-
Notifications
You must be signed in to change notification settings - Fork 4
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
Too Many Singletons (intention to drop) #4
Comments
jgvictores
changed the title
Too Many Singletons
Too Many Singletons (intention to drop)
Feb 9, 2015
Closed
PeterBowman
added a commit
that referenced
this issue
Apr 16, 2017
One could still create copies with the following code: // Create singleton MockImageManager::RegisterManager(); ImageManager * im = ImageManager::getImageManager(MockImageManager::id); // Violate singleton's contract with copy constructor MockImageManager * temp = (MockImageManager*)im; // for conciseness MockImageManager mim1(*temp); // copy-ctor #1 MockImageManager mim2 = *temp; // copy-ctor #2 MockImageManager mim3 = MockImageManager(*temp); // copy-ctor #3 MockImageManager *pmim = new MockImageManager(*temp); // copy-ctor #4 // Copy assignment operator mim1 = mim3; See also http://stackoverflow.com/a/6811055
Not actually speaking about singleton removal here, but the mechanism could be simplified by using local static variables instead of unique pointers, see robotology/yarp#1685. Edit: perhaps the relevant changes are easier to spot in robotology/yarp@51d9cec. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently there is controversy between developers about if there is an abuse of the Singleton pattern used in Robot Devastation.
This may serve as a discussion thread to try to arrive to an agreement.
The text was updated successfully, but these errors were encountered: