- 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:
parent
167f9ad437
commit
0a2f37345f
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
|
|
||||||
|
GlobalPreferences* GlobalPreferences::_instance = NULL;
|
||||||
|
|
||||||
GlobalPreferences::GlobalPreferences()
|
GlobalPreferences::GlobalPreferences()
|
||||||
: _mod_dirs(1, PLUGDIR), _pol_dirs(1, POLDIR)
|
: _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);
|
_pol_dirs.insert(_pol_dirs.begin(), poldir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GlobalPreferences&
|
||||||
|
GlobalPreferences::get_instance()
|
||||||
|
{
|
||||||
|
if(_instance == NULL)
|
||||||
|
_instance = new GlobalPreferences();
|
||||||
|
return *_instance;
|
||||||
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace sgpem {
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
namespace sgpem {
|
namespace sgpem {
|
||||||
class SG_DLLEXPORT GlobalPreferences : public Singleton<GlobalPreferences>
|
class SG_DLLEXPORT GlobalPreferences /*: public Singleton<GlobalPreferences>*/
|
||||||
{
|
{
|
||||||
friend class Singleton<GlobalPreferences>;
|
friend class Singleton<GlobalPreferences>;
|
||||||
|
|
||||||
|
@ -51,14 +51,18 @@ namespace sgpem {
|
||||||
void add_modules_dir(const Glib::ustring& moddir);
|
void add_modules_dir(const Glib::ustring& moddir);
|
||||||
void add_policies_dir(const Glib::ustring& poldir);
|
void add_policies_dir(const Glib::ustring& poldir);
|
||||||
|
|
||||||
|
static GlobalPreferences& get_instance();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GlobalPreferences();
|
GlobalPreferences();
|
||||||
GlobalPreferences(const GlobalPreferences&);
|
GlobalPreferences(const GlobalPreferences&);
|
||||||
GlobalPreferences& operator=(const GlobalPreferences&);
|
GlobalPreferences& operator=(const GlobalPreferences&);
|
||||||
|
|
||||||
std::vector<Glib::ustring> _mod_dirs;
|
std::vector<Glib::ustring> _mod_dirs;
|
||||||
std::vector<Glib::ustring> _pol_dirs;
|
std::vector<Glib::ustring> _pol_dirs;
|
||||||
};
|
|
||||||
|
static GlobalPreferences* _instance;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,6 +23,8 @@ using namespace std;
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
using namespace memory;
|
using namespace memory;
|
||||||
|
|
||||||
|
History* History::_instance = NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The constructor sets _total_time_elapsed to -1: this permits to insert the INITIAL STATUS
|
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.
|
of the simulation which must begin at instant -1 and live for 1 instant.
|
||||||
|
@ -133,6 +135,12 @@ History::truncate_at(int instant)
|
||||||
notify();
|
notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
History&
|
||||||
|
History::get_instance()
|
||||||
|
{
|
||||||
|
if(_instance == NULL)
|
||||||
|
_instance = new History();
|
||||||
|
return *_instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ namespace sgpem
|
||||||
*/
|
*/
|
||||||
class History;
|
class History;
|
||||||
|
|
||||||
class SG_DLLEXPORT History : public Singleton<History>, public ObservedSubject
|
class SG_DLLEXPORT History : /*public Singleton<History>,*/ public ObservedSubject
|
||||||
{
|
{
|
||||||
friend class Singleton<History>;
|
friend class Singleton<History>;
|
||||||
|
|
||||||
|
@ -85,6 +85,8 @@ namespace sgpem
|
||||||
\param instant Desired cutting time.
|
\param instant Desired cutting time.
|
||||||
*/
|
*/
|
||||||
virtual void truncate_at(int instant);
|
virtual void truncate_at(int instant);
|
||||||
|
|
||||||
|
static History& get_instance();
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -95,6 +97,7 @@ namespace sgpem
|
||||||
private:
|
private:
|
||||||
int _total_time_elapsed;
|
int _total_time_elapsed;
|
||||||
std::vector<sgpem::Slice> _slices;
|
std::vector<sgpem::Slice> _slices;
|
||||||
|
static History* _instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
}//~ namespace sgpem
|
}//~ namespace sgpem
|
||||||
|
|
|
@ -34,6 +34,8 @@ using namespace sgpem;
|
||||||
typedef vector<PolicyManager*>::iterator ManagerIterator;
|
typedef vector<PolicyManager*>::iterator ManagerIterator;
|
||||||
typedef map<History*, Policy*>::iterator ActiveIterator;
|
typedef map<History*, Policy*>::iterator ActiveIterator;
|
||||||
|
|
||||||
|
PoliciesGatekeeper* PoliciesGatekeeper::_instance = NULL;
|
||||||
|
|
||||||
vector<PolicyManager*>
|
vector<PolicyManager*>
|
||||||
PoliciesGatekeeper::get_registered() const
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace sgpem
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class SG_DLLEXPORT PoliciesGatekeeper : public Singleton<PoliciesGatekeeper>
|
class SG_DLLEXPORT PoliciesGatekeeper /*: public Singleton<PoliciesGatekeeper>*/
|
||||||
{
|
{
|
||||||
friend class Singleton<PoliciesGatekeeper>;
|
friend class Singleton<PoliciesGatekeeper>;
|
||||||
|
|
||||||
|
@ -59,6 +59,8 @@ namespace sgpem
|
||||||
Policy* get_current_policy(History* history) throw(std::runtime_error);
|
Policy* get_current_policy(History* history) throw(std::runtime_error);
|
||||||
|
|
||||||
void activate_policy(History* history, Policy* policy);
|
void activate_policy(History* history, Policy* policy);
|
||||||
|
|
||||||
|
static PoliciesGatekeeper& get_instance();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PoliciesGatekeeper(); //private constructor.
|
PoliciesGatekeeper(); //private constructor.
|
||||||
|
@ -70,8 +72,9 @@ namespace sgpem
|
||||||
|
|
||||||
std::vector<PolicyManager*> _registered;
|
std::vector<PolicyManager*> _registered;
|
||||||
std::map<History*, Policy*> _active_policies;
|
std::map<History*, Policy*> _active_policies;
|
||||||
|
static PoliciesGatekeeper* _instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
}//~ namespace sgpem
|
}//~ namespace sgpem
|
||||||
|
|
||||||
#endif //POLICIES_GATEKEEPER_HH
|
#endif //POLICIES_GATEKEEPER_HH
|
||||||
|
|
|
@ -29,6 +29,8 @@ using namespace std;
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
using namespace memory;
|
using namespace memory;
|
||||||
|
|
||||||
|
Scheduler* Scheduler::_instance = NULL;
|
||||||
|
|
||||||
//private constructor. The parameter is discarded
|
//private constructor. The parameter is discarded
|
||||||
Scheduler::Scheduler()
|
Scheduler::Scheduler()
|
||||||
: _policy_manager(PolicyManager::get_registered_manager())
|
: _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;
|
||||||
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace sgpem
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class SG_DLLEXPORT Scheduler : public Singleton<Scheduler>
|
class SG_DLLEXPORT Scheduler /*: public Singleton<Scheduler>*/
|
||||||
{
|
{
|
||||||
friend class Singleton<Scheduler>;
|
friend class Singleton<Scheduler>;
|
||||||
public:
|
public:
|
||||||
|
@ -86,13 +86,16 @@ namespace sgpem
|
||||||
Returns the policy that will be used to generate the simulation at the next instant.
|
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.
|
\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:
|
private:
|
||||||
Scheduler(); //private constructor.
|
Scheduler(); //private constructor.
|
||||||
SchedulableQueue _ready_queue;
|
SchedulableQueue _ready_queue;
|
||||||
PolicyManager& _policy_manager;
|
PolicyManager& _policy_manager;
|
||||||
|
static Scheduler* _instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
}//~ namespace sgpem
|
}//~ namespace sgpem
|
||||||
|
|
Loading…
Reference in New Issue