- Separate template definition from template declaration

- Explicitly instantiate Singleton templates to be exported from libbackend.so
- Install only header files that are backend interfaces to be exposed to the user
- Don't use full path for including templates in header files
- Instantiate a couple of smart_ptr templates to have their symbols exported outside the DSO. This happens in history.cc. FIXME: the interface for History will definitely need to be reworked, and the two smart_ptr explicit instantiations removed.
- Change SWIG exported interface to make use of Schedulable instead of (Dynamic|Static)Schedulable
- Fix provided policies to make use of the new interface
- TODO: limit the use of smart_ptrs.


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@653 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-06-23 13:06:39 +00:00
parent 56db7cd6a2
commit 66d46db357
37 changed files with 153 additions and 145 deletions

View file

@ -27,7 +27,6 @@
#include <vector>
#include "process.hh"
#include "../templates/smartp.hh"
#include "dynamic_schedulable.hh"
namespace sgpem

View file

@ -21,6 +21,9 @@
#include "dynamic_request.hh"
#include "static_request.hh"
#include "dynamic_sub_request.hh"
#include "smartp.tcc"
#include <cassert>
using namespace sgpem;

View file

@ -22,11 +22,14 @@
#define DYNAMIC_REQUEST_HH 1
#include "config.h"
#include "../templates/smartp.hh"
#include <vector>
#include "request.hh"
#include "static_request.hh"
#include "smartp.hh"
#include <vector>
namespace sgpem
{
class DynamicRequest;

View file

@ -21,6 +21,8 @@
#include "dynamic_resource.hh"
#include "static_resource.hh"
#include "smartp.tcc"
using namespace sgpem;
DynamicResource::DynamicResource(StaticResource *core) :

View file

@ -23,7 +23,8 @@
#include "config.h"
#include "glibmm/ustring.h"
#include "../templates/smartp.hh"
#include "smartp.hh"
#include "resource.hh"

View file

@ -20,6 +20,8 @@
#include "dynamic_schedulable.hh"
#include "smartp.tcc"
using namespace sgpem;
using namespace std;

View file

@ -24,7 +24,8 @@
#include "config.h"
#include "schedulable.hh"
#include "static_schedulable.hh"
#include "../templates/smartp.hh"
#include "smartp.hh"
namespace sgpem
{

View file

@ -20,6 +20,10 @@
#include "dynamic_sub_request.hh"
#include "smartp.tcc"
#include <cassert>
using namespace sgpem;
DynamicSubRequest::DynamicSubRequest(StaticSubRequest* core,

View file

@ -26,6 +26,8 @@
#include "dynamic_resource.hh"
#include "static_sub_request.hh"
#include "smartp.hh"
namespace sgpem
{
class DynamicSubRequest;

View file

@ -23,6 +23,8 @@
#include "dynamic_request.hh"
#include <cassert>
#include "smartp.tcc"
using namespace sgpem;
using std::vector;

View file

@ -28,9 +28,10 @@
#include "thread.hh"
#include "dynamic_process.hh"
#include "../templates/smartp.hh"
#include "dynamic_schedulable.hh"
#include "smartp.hh"
namespace sgpem
{
class DynamicThread;

View file

@ -21,9 +21,12 @@
#include "config.h"
#include "global_preferences.hh"
// Do not include in header file:
#include "singleton.tcc"
using namespace sgpem;
GlobalPreferences* GlobalPreferences::_instance = NULL;
// Explicit template instantiation to allow to export symbols from the DSO.
template class SG_DLLEXPORT Singleton<GlobalPreferences>;
GlobalPreferences::GlobalPreferences()
: _mod_dirs(1, PLUGDIR), _pol_dirs(1, POLDIR)
@ -71,10 +74,3 @@ 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

@ -26,6 +26,7 @@
#include <glibmm/ustring.h>
#include <vector>
// Do not include complete template definition here:
#include "singleton.hh"
namespace sgpem {
@ -35,7 +36,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,8 +52,6 @@ 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&);
@ -60,8 +59,6 @@ namespace sgpem {
std::vector<Glib::ustring> _mod_dirs;
std::vector<Glib::ustring> _pol_dirs;
static GlobalPreferences* _instance;
};
}

View file

@ -18,12 +18,24 @@
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "config.h"
#include "history.hh"
// Do not include in header file:
#include "singleton.tcc"
#include "smartp.tcc"
using namespace std;
using namespace sgpem;
using namespace memory;
History* History::_instance = NULL;
// Explicit template instantiation to allow to export symbols from the DSO.
template class SG_DLLEXPORT Singleton<History>;
// FIXME: These two should disappear!!!
template class SG_DLLEXPORT smart_ptr<SchedulableQueue>;
template class SG_DLLEXPORT smart_ptr<DynamicSchedulable>;
/**
The constructor sets _total_time_elapsed to -1: this permits to insert the INITIAL STATUS
@ -135,12 +147,3 @@ History::truncate_at(int instant)
notify();
}
History&
History::get_instance()
{
if(_instance == NULL)
_instance = new History();
return *_instance;
}

View file

@ -30,8 +30,9 @@
#include "observed_subject.hh"
#include "schedulable_queue.hh"
#include "dynamic_schedulable.hh"
#include "../templates/smartp.hh"
#include "smartp.hh"
// Do not include complete template definition here:
#include "singleton.hh"
namespace sgpem
@ -49,7 +50,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,9 +87,6 @@ namespace sgpem
*/
virtual void truncate_at(int instant);
static History& get_instance();
protected:
History(); //private constructor.
History(const History&);
@ -97,7 +95,6 @@ namespace sgpem
private:
int _total_time_elapsed;
std::vector<sgpem::Slice> _slices;
static History* _instance;
};
}//~ namespace sgpem

View file

@ -18,10 +18,15 @@
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "config.h"
#include "policies_gatekeeper.hh"
#include "policy_manager.hh"
#include "policy.hh"
// Include full template definition only in implementation files:
#include "singleton.tcc"
#include <algorithm>
#include <cassert>
@ -31,11 +36,12 @@ using std::find;
using std::runtime_error;
using namespace sgpem;
// Explicit template instantiation to allow to export symbols from the DSO.
template class SG_DLLEXPORT Singleton<PoliciesGatekeeper>;
typedef vector<PolicyManager*>::iterator ManagerIterator;
typedef map<History*, Policy*>::iterator ActiveIterator;
PoliciesGatekeeper* PoliciesGatekeeper::_instance = NULL;
vector<PolicyManager*>
PoliciesGatekeeper::get_registered() const
{
@ -131,11 +137,3 @@ 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,8 +60,6 @@ namespace sgpem
void activate_policy(History* history, Policy* policy);
static PoliciesGatekeeper& get_instance();
private:
PoliciesGatekeeper(); //private constructor.
PoliciesGatekeeper(const PoliciesGatekeeper&);
@ -72,7 +70,6 @@ namespace sgpem
std::vector<PolicyManager*> _registered;
std::map<History*, Policy*> _active_policies;
static PoliciesGatekeeper* _instance;
};
}//~ namespace sgpem

View file

@ -48,7 +48,7 @@ namespace sgpem
state_terminated = 1<<4
};
virtual ~Schedulable();
virtual ~Schedulable() = 0;
virtual Glib::ustring get_name() const = 0;

View file

@ -20,6 +20,8 @@
#include "schedulable_queue.hh"
#include "smartp.tcc"
using namespace sgpem;
using namespace std;
using namespace memory;

View file

@ -23,10 +23,11 @@
#include "config.h"
#include <list>
#include "dynamic_schedulable.hh"
#include "../templates/smartp.hh"
#include "smartp.hh"
#include <list>
namespace sgpem

View file

@ -24,12 +24,16 @@
#include "policies_gatekeeper.hh"
#include "user_interrupt_exception.hh"
// Do not include full template definition in the header file
#include "singleton.tcc"
#include <iostream>
using namespace std;
using namespace sgpem;
using namespace memory;
Scheduler* Scheduler::_instance = NULL;
// Explicit template instantiation to allow to export symbols from the DSO.
template class SG_DLLEXPORT Singleton<Scheduler>;
//private constructor. The parameter is discarded
Scheduler::Scheduler()
@ -207,10 +211,3 @@ Scheduler::step_forward() throw(UserInterruptException)
}
}
Scheduler&
Scheduler::get_instance()
{
if(_instance == NULL)
_instance = new Scheduler();
return *_instance;
}

View file

@ -37,6 +37,7 @@ namespace sgpem
#include "schedulable_queue.hh"
#include "user_interrupt_exception.hh"
// Do not include full template definition here
#include "singleton.hh"
namespace sgpem
@ -54,7 +55,7 @@ namespace sgpem
*/
class SG_DLLEXPORT Scheduler /*: public Singleton<Scheduler>*/
class SG_DLLEXPORT Scheduler : public Singleton<Scheduler>
{
friend class Singleton<Scheduler>;
public:
@ -88,14 +89,10 @@ namespace sgpem
*/
Policy& get_policy();
static Scheduler& get_instance();
private:
Scheduler(); //private constructor.
SchedulableQueue _ready_queue;
PolicyManager& _policy_manager;
static Scheduler* _instance;
};
}//~ namespace sgpem

View file

@ -21,6 +21,8 @@
#include "static_thread.hh"
#include "static_request.hh"
#include <cassert>
using namespace sgpem;
using std::vector;