I have a class which currently defines a static variables that stores several parameters list.
static list<shared_ptr<ParameterContainer> > _containers
These ParameterContainers
should be accessible by different clients.
The ParameterContainers
are created by the constructor of the class, which receives a path as input, reads values from XML files contained in the path and stores the new ParameterContainers
in _containers
. The constructor control that the files have not been already stored.
Clients can access, modify and save on the XML files the parameters values.
The variable _containers
is protected by a mutex, which guarantee the correct shared access.
I think that having a central repository for this parameters is good, it avoids to loading it every time from a file. This is actually achieved by means of the static variable _containers
.
I'm wondering if it would be better to implement the entire class a singleton and remove the keyword static from the variable _containters
.
I read several discussions about the fact that the singleton could be an anti-pattern. I would like to know a good reason for avoiding singleton in this case.