- 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,13 +51,17 @@ 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;
};
}

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>;
@ -86,6 +86,8 @@ namespace sgpem
*/
virtual void truncate_at(int instant);
static History& get_instance();
protected:
History(); //private constructor.
@ -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
{
@ -129,3 +131,11 @@ 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>;
@ -60,6 +60,8 @@ namespace sgpem
void activate_policy(History* history, Policy* policy);
static PoliciesGatekeeper& get_instance();
private:
PoliciesGatekeeper(); //private constructor.
PoliciesGatekeeper(const PoliciesGatekeeper&);
@ -70,6 +72,7 @@ namespace sgpem
std::vector<PolicyManager*> _registered;
std::map<History*, Policy*> _active_policies;
static PoliciesGatekeeper* _instance;
};
}//~ namespace sgpem

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:
@ -88,11 +88,14 @@ namespace sgpem
*/
Policy& get_policy();
static Scheduler& get_instance();
private:
Scheduler(); //private constructor.
SchedulableQueue _ready_queue;
PolicyManager& _policy_manager;
static Scheduler* _instance;
};
}//~ namespace sgpem