- Temporarily disabled template-based singleton system because of a crash virtually surely caused by it

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@648 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
elvez 2006-06-21 20:24:36 +00:00
parent 167f9ad437
commit 0a2f37345f
8 changed files with 60 additions and 11 deletions

View File

@ -23,6 +23,8 @@
using namespace sgpem;
GlobalPreferences* GlobalPreferences::_instance = NULL;
GlobalPreferences::GlobalPreferences()
: _mod_dirs(1, PLUGDIR), _pol_dirs(1, POLDIR)
{}
@ -69,3 +71,10 @@ GlobalPreferences::add_policies_dir(const Glib::ustring& poldir)
_pol_dirs.insert(_pol_dirs.begin(), poldir);
}
GlobalPreferences&
GlobalPreferences::get_instance()
{
if(_instance == NULL)
_instance = new GlobalPreferences();
return *_instance;
}

View File

@ -35,7 +35,7 @@ namespace sgpem {
#include "config.h"
namespace sgpem {
class SG_DLLEXPORT GlobalPreferences : public Singleton<GlobalPreferences>
class SG_DLLEXPORT GlobalPreferences /*: public Singleton<GlobalPreferences>*/
{
friend class Singleton<GlobalPreferences>;
@ -51,14 +51,18 @@ namespace sgpem {
void add_modules_dir(const Glib::ustring& moddir);
void add_policies_dir(const Glib::ustring& poldir);
static GlobalPreferences& get_instance();
private:
GlobalPreferences();
GlobalPreferences(const GlobalPreferences&);
GlobalPreferences& operator=(const GlobalPreferences&);
std::vector<Glib::ustring> _mod_dirs;
std::vector<Glib::ustring> _pol_dirs;
};
std::vector<Glib::ustring> _mod_dirs;
std::vector<Glib::ustring> _pol_dirs;
static GlobalPreferences* _instance;
};
}
#endif

View File

@ -23,6 +23,8 @@ using namespace std;
using namespace sgpem;
using namespace memory;
History* History::_instance = NULL;
/**
The constructor sets _total_time_elapsed to -1: this permits to insert the INITIAL STATUS
of the simulation which must begin at instant -1 and live for 1 instant.
@ -133,6 +135,12 @@ History::truncate_at(int instant)
notify();
}
History&
History::get_instance()
{
if(_instance == NULL)
_instance = new History();
return *_instance;
}

View File

@ -49,7 +49,7 @@ namespace sgpem
*/
class History;
class SG_DLLEXPORT History : public Singleton<History>, public ObservedSubject
class SG_DLLEXPORT History : /*public Singleton<History>,*/ public ObservedSubject
{
friend class Singleton<History>;
@ -85,6 +85,8 @@ namespace sgpem
\param instant Desired cutting time.
*/
virtual void truncate_at(int instant);
static History& get_instance();
protected:
@ -95,6 +97,7 @@ namespace sgpem
private:
int _total_time_elapsed;
std::vector<sgpem::Slice> _slices;
static History* _instance;
};
}//~ namespace sgpem

View File

@ -34,6 +34,8 @@ using namespace sgpem;
typedef vector<PolicyManager*>::iterator ManagerIterator;
typedef map<History*, Policy*>::iterator ActiveIterator;
PoliciesGatekeeper* PoliciesGatekeeper::_instance = NULL;
vector<PolicyManager*>
PoliciesGatekeeper::get_registered() const
{
@ -128,4 +130,12 @@ PoliciesGatekeeper::deactivate_policies(PolicyManager* manager)
}
}
}
PoliciesGatekeeper&
PoliciesGatekeeper::get_instance()
{
if(_instance == NULL)
_instance = new PoliciesGatekeeper();
return *_instance;
}

View File

@ -45,7 +45,7 @@ namespace sgpem
*/
class SG_DLLEXPORT PoliciesGatekeeper : public Singleton<PoliciesGatekeeper>
class SG_DLLEXPORT PoliciesGatekeeper /*: public Singleton<PoliciesGatekeeper>*/
{
friend class Singleton<PoliciesGatekeeper>;
@ -59,6 +59,8 @@ namespace sgpem
Policy* get_current_policy(History* history) throw(std::runtime_error);
void activate_policy(History* history, Policy* policy);
static PoliciesGatekeeper& get_instance();
private:
PoliciesGatekeeper(); //private constructor.
@ -70,8 +72,9 @@ namespace sgpem
std::vector<PolicyManager*> _registered;
std::map<History*, Policy*> _active_policies;
static PoliciesGatekeeper* _instance;
};
}//~ namespace sgpem
#endif //POLICIES_GATEKEEPER_HH

View File

@ -29,6 +29,8 @@ using namespace std;
using namespace sgpem;
using namespace memory;
Scheduler* Scheduler::_instance = NULL;
//private constructor. The parameter is discarded
Scheduler::Scheduler()
: _policy_manager(PolicyManager::get_registered_manager())
@ -205,3 +207,10 @@ Scheduler::step_forward() throw(UserInterruptException)
}
}
Scheduler&
Scheduler::get_instance()
{
if(_instance == NULL)
_instance = new Scheduler();
return *_instance;
}

View File

@ -54,7 +54,7 @@ namespace sgpem
*/
class SG_DLLEXPORT Scheduler : public Singleton<Scheduler>
class SG_DLLEXPORT Scheduler /*: public Singleton<Scheduler>*/
{
friend class Singleton<Scheduler>;
public:
@ -86,13 +86,16 @@ namespace sgpem
Returns the policy that will be used to generate the simulation at the next instant.
\return the policy that will be used to generate the simulation at the next instant.
*/
Policy& get_policy();
Policy& get_policy();
static Scheduler& get_instance();
private:
Scheduler(); //private constructor.
SchedulableQueue _ready_queue;
PolicyManager& _policy_manager;
static Scheduler* _instance;
};
}//~ namespace sgpem