Replace autotools with CMake at the toplevel, backend now compiles with newer GCC

This commit is contained in:
Matteo Settenvini 2018-09-25 09:56:28 +02:00
parent d50ec337d1
commit 616aef27a8
124 changed files with 1242 additions and 6315 deletions

View file

@ -26,12 +26,12 @@
using namespace sgpem;
// Is this OK? If not, we must use a function with a local static variable...
PythonCPUPolicyManager* _policy_manager = NULL;
PythonCPUPolicyManager* _policy_manager = nullptr;
void
sgpem__Plugin__on_init()
{
if (_policy_manager == NULL)
if (_policy_manager == nullptr)
_policy_manager = new sgpem::PythonCPUPolicyManager();
}
@ -39,7 +39,7 @@ void
sgpem__Plugin__on_exit()
{
delete _policy_manager;
_policy_manager = NULL;
_policy_manager = nullptr;
}
const char*

View file

@ -63,14 +63,14 @@ namespace sgpem
// WARNING : this class needs extensive and above all
// *strong* exception checking / handling!
PythonCPUPolicy::PythonCPUPolicy(const char* name) throw(MalformedPolicyException)
PythonCPUPolicy::PythonCPUPolicy(const char* name)
: _upolicy_dict(NULL), _adapter(NULL), _name(name), _description()
{
PyObject* pLoadmeStr = PyUnicode_FromString (name);
PyObject* pUserCPUPolicyModule = PyImport_Import(pLoadmeStr);
Py_DECREF(pLoadmeStr);
if (pUserCPUPolicyModule == NULL)
if (pUserCPUPolicyModule == nullptr)
throw MalformedPolicyException(get_exception_information());
// Dictionary with defined ``symbols'' for .pyc file
@ -87,7 +87,7 @@ PythonCPUPolicy::PythonCPUPolicy(const char* name) throw(MalformedPolicyExceptio
// Now takes the user-defined policy class from pUserCPUPolicyDict
PyObject* pCPUPolicyClass = PyDict_GetItemString(_upolicy_dict, name);
if (pCPUPolicyClass == NULL)
if (pCPUPolicyClass == nullptr)
throw new MalformedPolicyException (Glib::ustring::compose (
_("Cannot find a class named %1 into the corresponding .py file."),
name));
@ -109,7 +109,7 @@ PythonCPUPolicy::PythonCPUPolicy(const char* name) throw(MalformedPolicyExceptio
Py_DECREF(pScriptAdapterModule);
if (_adapter == NULL)
if (_adapter == nullptr)
throw MalformedPolicyException(get_exception_information());
// And now, who's your daddy, huh?
@ -127,7 +127,7 @@ PythonCPUPolicy::~PythonCPUPolicy()
}
void
PythonCPUPolicy::activate() throw(UserInterruptException, MalformedPolicyException)
PythonCPUPolicy::activate()
{
Glib::RecMutex::Lock lock(_mtx);;
set_callback_policy(const_cast<PythonCPUPolicy*>(this));
@ -157,12 +157,12 @@ PythonCPUPolicy::deactivate()
void
PythonCPUPolicy::configure() throw(UserInterruptException, MalformedPolicyException)
PythonCPUPolicy::configure()
{
Glib::RecMutex::Lock lock(_mtx);;
set_callback_policy(const_cast<PythonCPUPolicy*>(this));
PyObject* retval = PyObject_CallMethod(_adapter, const_cast<char*>("async_configure"), NULL);
PyObject* retval = PyObject_CallMethod(_adapter, const_cast<char*>("async_configure"), nullptr);
Py_DECREF(retval);
wait_unlock();
@ -172,12 +172,12 @@ PythonCPUPolicy::configure() throw(UserInterruptException, MalformedPolicyExcept
void
PythonCPUPolicy::sort_queue() const throw(UserInterruptException, MalformedPolicyException)
PythonCPUPolicy::sort_queue() const
{
Glib::RecMutex::Lock lock(_mtx);;
set_callback_policy(const_cast<PythonCPUPolicy*>(this));
PyObject* retval = PyObject_CallMethod(_adapter, const_cast<char*>("async_sort_queue"), NULL);
PyObject* retval = PyObject_CallMethod(_adapter, const_cast<char*>("async_sort_queue"), nullptr);
// Do minimal debugging
if (!retval) PyErr_Print();
@ -203,18 +203,18 @@ PythonCPUPolicy::get_name() const
}
bool
PythonCPUPolicy::is_pre_emptive() const throw(UserInterruptException, MalformedPolicyException)
PythonCPUPolicy::is_pre_emptive() const
{
Glib::RecMutex::Lock lock(_mtx);;
set_callback_policy(const_cast<PythonCPUPolicy*>(this));
PyObject* retval = PyObject_CallMethod(_adapter, const_cast<char*>("async_is_preemptive"), NULL);
PyObject* retval = PyObject_CallMethod(_adapter, const_cast<char*>("async_is_preemptive"), nullptr);
Py_DECREF(retval);
wait_unlock();
// Parse return value stored in global Python object
retval = PyObject_CallMethod(_adapter, const_cast<char*>("get_return_value"), NULL);
retval = PyObject_CallMethod(_adapter, const_cast<char*>("get_return_value"), nullptr);
assert(retval);
bool ret = PyObject_IsTrue(retval);
Py_DECREF(retval);
@ -225,12 +225,12 @@ PythonCPUPolicy::is_pre_emptive() const throw(UserInterruptException, MalformedP
int
PythonCPUPolicy::get_time_slice() const throw(UserInterruptException, MalformedPolicyException)
PythonCPUPolicy::get_time_slice() const
{
Glib::RecMutex::Lock lock(_mtx);;
set_callback_policy(const_cast<PythonCPUPolicy*>(this));
PyObject* retval = PyObject_CallMethod(_adapter, const_cast<char*>("async_get_time_slice"), NULL);
PyObject* retval = PyObject_CallMethod(_adapter, const_cast<char*>("async_get_time_slice"), nullptr);
// Do minimal debugging
if (!retval) PyErr_Print();
@ -239,7 +239,7 @@ PythonCPUPolicy::get_time_slice() const throw(UserInterruptException, MalformedP
wait_unlock();
// Parse return value stored in global Python object
retval = PyObject_CallMethod(_adapter, const_cast<char*>("get_return_value"), NULL);
retval = PyObject_CallMethod(_adapter, const_cast<char*>("get_return_value"), nullptr);
assert(retval);
long tmp = PyLong_AsLong(retval);
Py_DECREF(retval);
@ -250,7 +250,7 @@ PythonCPUPolicy::get_time_slice() const throw(UserInterruptException, MalformedP
void
PythonCPUPolicy::wait_unlock() const throw(UserInterruptException, MalformedPolicyException)
PythonCPUPolicy::wait_unlock() const
{
// Polling time
static const int wait_for = 150000;
@ -266,7 +266,7 @@ PythonCPUPolicy::wait_unlock() const throw(UserInterruptException, MalformedPoli
Glib::usleep(wait_for); // hack'a'ton! magggggiccc nummmbeeerrrrrs!!
Py_BLOCK_THREADS;
PyObject* retval = PyObject_CallMethod(_adapter, const_cast<char*>("mutex_test_lock"), NULL);
PyObject* retval = PyObject_CallMethod(_adapter, const_cast<char*>("mutex_test_lock"), nullptr);
assert(retval);
still_locked = PyObject_IsTrue(retval);
Py_DECREF(retval);
@ -279,7 +279,7 @@ PythonCPUPolicy::wait_unlock() const throw(UserInterruptException, MalformedPoli
Py_UNBLOCK_THREADS;
PyEval_RestoreThread(_save);
if(PyErr_Occurred() != NULL)
if(PyErr_Occurred() != nullptr)
abort();
throw UserInterruptException(_("User-defined policy is "
@ -290,9 +290,9 @@ PythonCPUPolicy::wait_unlock() const throw(UserInterruptException, MalformedPoli
// check if there were unhandled exception in the user-defined code
PyObject* pException = PyObject_CallMethod(_adapter, const_cast<char*>("get_last_exception"), NULL);
PyObject* pException = PyObject_CallMethod(_adapter, const_cast<char*>("get_last_exception"), nullptr);
if(pException != NULL)
if(pException != nullptr)
{
if(pException != Py_None)
{
@ -326,18 +326,18 @@ PythonCPUPolicy::wait_unlock() const throw(UserInterruptException, MalformedPoli
string
PythonCPUPolicy::get_exception_information()
{
if (PyErr_Occurred() == NULL)
if (PyErr_Occurred() == nullptr)
return _("no error");
PyObject* pType = NULL;
PyObject* pValue = NULL;
PyObject* pTraceback = NULL;
PyObject* pType = nullptr;
PyObject* pValue = nullptr;
PyObject* pTraceback = nullptr;
PyErr_Fetch(&pType, &pValue, &pTraceback);
string msg;
if (pValue != NULL)
if (pValue != nullptr)
{
msg = sgpem::PyString_AsString(pValue) + "\n";
PyErr_PrintEx (false);
@ -345,9 +345,9 @@ PythonCPUPolicy::get_exception_information()
else
msg = string(_("no available information for this error"));
if (pType != NULL) { Py_DECREF(pType); }
if (pValue != NULL) { Py_DECREF(pValue); }
if (pTraceback != NULL) { Py_DECREF(pTraceback); }
if (pType != nullptr) { Py_DECREF(pType); }
if (pValue != nullptr) { Py_DECREF(pValue); }
if (pTraceback != nullptr) { Py_DECREF(pTraceback); }
PyErr_Clear();

View file

@ -71,7 +71,7 @@ namespace sgpem
/// @see activate().
/// @throw an exception when the policy is malformed and therefore not usable.
/// @param name the name of the policy
PythonCPUPolicy(const char* name) throw(MalformedPolicyException);
PythonCPUPolicy(const char* name);
/// \brief Standard virtual destructor
///
@ -89,7 +89,7 @@ namespace sgpem
/// @throw an exception when the policy is malformed and therefore not usable,
/// or when the policy is taking too long to terminate its work.
/// @see ::CPUPolicy::configure().
void configure() throw(UserInterruptException, MalformedPolicyException);
void configure();
/// \brief Sorts the queue, asynchronously.
///
@ -97,7 +97,7 @@ namespace sgpem
/// @throw an exception when the policy is malformed and therefore not usable,
/// or when the policy is taking too long to terminate its work.
/// @see ::CPUPolicy::sort_queue().
void sort_queue() const throw(UserInterruptException, MalformedPolicyException);
void sort_queue() const;
/// \brief Returns a textual description of the policy.
///
@ -126,7 +126,7 @@ namespace sgpem
/// @return \c TRUE if the policy is preemptive.
/// @return \c FALSE if the policy is not preemptive.
/// @see ::CPUPolicy::is_pre_emptive().
bool is_pre_emptive() const throw(UserInterruptException, MalformedPolicyException);
bool is_pre_emptive() const;
/// \brief Returns the lenght of the time slice, asynchronously.
///
@ -136,7 +136,7 @@ namespace sgpem
/// or when the policy is taking too long to terminate its work.
/// @return the lenght of the time slice.
/// @see ::CPUPolicy::get_time_slice().
int get_time_slice() const throw(UserInterruptException, MalformedPolicyException);
int get_time_slice() const;
/// \brief Load the corresponding Python module and initialize a new Policy object (in Python).
///
@ -144,7 +144,7 @@ namespace sgpem
/// @throw an exception when the policy is malformed and therefore not usable,
/// or when the policy is taking too long to terminate its work.
/// @see ::CPUPolicy::activate().
void activate() throw(UserInterruptException, MalformedPolicyException);
void activate();
/// \brief Activates the policy.
///
@ -168,7 +168,7 @@ namespace sgpem
/// the lock is taken again, and we check if the thread has finished via
/// the mutex present in ::ScriptAdapter. If so, wait_unlock() terminates
/// successfully. Else it stays in its main loop.
void wait_unlock() const throw(UserInterruptException, MalformedPolicyException);
void wait_unlock() const;
/// \brief Returns a brief description of a thrown exception.
/// Returns the description of the exception occurred.

View file

@ -22,8 +22,6 @@
#include <sgpemv2/global_preferences.hh>
#include <sgpemv2/cpu_policies_gatekeeper.hh>
#include <sgpemv2/templates/deletor.tcc>
#include <glibmm/ustring.h>
#include <glibmm/timer.h>
#include <glibmm/fileutils.h>
@ -104,7 +102,7 @@ PythonCPUPolicyManager::PythonCPUPolicyManager()
PythonCPUPolicyManager::~PythonCPUPolicyManager()
{
for_each(_policies.begin(), _policies.end(), memory::deletor<CPUPolicy>());
for_each(_policies.begin(), _policies.end(), [] (auto *p) { delete p; });
}
@ -124,7 +122,7 @@ PythonCPUPolicyManager::collect_policies()
for (; dir_it != dir_end; ++dir_it)
{
Glib::Dir dir(*dir_it);
#ifndef NDEBUG
std::clog << "Opening directory " << *dir_it << " looking for python policies..." << endl;
#endif
@ -137,7 +135,7 @@ PythonCPUPolicyManager::collect_policies()
if (dot_py.match(*file_it))
{
#ifndef NDEBUG
std::clog << *file_it << " appears to be a Python script. Attempting to load..." << std::endl;
std::clog << *file_it << " appears to be a Python script. Attempting to load..." << std::endl;
#endif
//strip extension
std::string policy_name = (*file_it).substr(0, (*file_it).size() - 3);

View file

@ -86,7 +86,7 @@ namespace sgpem {
virtual ~CPUPolicy() = 0;
sgpem::PolicyParameters& get_parameters();
static CPUPolicy* callback_get_policy() throw(std::runtime_error);
static CPUPolicy* callback_get_policy();
};
// --------------------------------------------
@ -237,8 +237,8 @@ namespace sgpem {
sgpem::Thread& get_item_at(position index);
void swap(position a, position b) throw(std::out_of_range);
void bubble_to_front(position x) throw(std::out_of_range);
void swap(position a, position b);
void bubble_to_front(position x);
private:
// Avoid instantiation and copy

View file

@ -49,7 +49,7 @@ find_pol_by_name(const vector<CPUPolicy*>& pols, const Glib::ustring& name)
for ( ; it != pols.end(); it++)
if ((*it)->get_name() == name)
return *it;
return NULL;
return nullptr;
}
@ -89,7 +89,7 @@ main(int argc, char** argv)
try
{
CPUPolicy* pol = find_pol_by_name(policies, "python_loader_configure");
assert(pol != NULL);
assert(pol != nullptr);
// activate_policy will also configure the policy
pgk.activate_policy(&his, pol);
@ -104,7 +104,7 @@ main(int argc, char** argv)
try
{
CPUPolicy* pol = find_pol_by_name(policies, "python_loader_is_preemptive");
assert(pol != NULL);
assert(pol != nullptr);
pgk.activate_policy(&his, pol);
pol->is_pre_emptive();
}
@ -118,7 +118,7 @@ main(int argc, char** argv)
try
{
CPUPolicy* pol = find_pol_by_name(policies, "python_loader_get_time_slice");
assert(pol != NULL);
assert(pol != nullptr);
pgk.activate_policy(&his, pol);
pol->get_time_slice();
}
@ -133,7 +133,7 @@ main(int argc, char** argv)
try
{
CPUPolicy* pol = find_pol_by_name(policies, "python_loader_get_time_slice");
assert(pol != NULL);
assert(pol != nullptr);
pgk.activate_policy(&his, pol);
pol->sort_queue();
}

View file

@ -26,12 +26,12 @@
using namespace sgpem;
sgpem::XMLSerializer* _serializer = NULL;
sgpem::XMLSerializer* _serializer = nullptr;
void
sgpem__Plugin__on_init()
{
if (_serializer == NULL)
if (_serializer == nullptr)
_serializer = new sgpem::XMLSerializer();
}
@ -39,7 +39,7 @@ void
sgpem__Plugin__on_exit()
{
delete _serializer;
_serializer = NULL;
_serializer = nullptr;
}
const char*

View file

@ -38,7 +38,7 @@ XMLSerializer::XMLSerializer()
void XMLSerializer::save_snapshot(const Glib::ustring& filename, const History& hist) throw(SerializerError)
void XMLSerializer::save_snapshot(const Glib::ustring& filename, const History& hist)
{
/* COMPAT: Do not genrate nodes for formatting spaces */
LIBXML_TEST_VERSION
@ -46,7 +46,7 @@ void XMLSerializer::save_snapshot(const Glib::ustring& filename, const History&
xmlDocPtr doc;
doc = xmlNewDoc((const xmlChar *)"1.0");
if (doc != NULL)
if (doc != nullptr)
{
fill_doc(doc, hist);
int nwritten = xmlSaveFormatFile (filename.c_str(), doc, 1);
@ -64,7 +64,7 @@ void XMLSerializer::save_snapshot(const Glib::ustring& filename, const History&
xmlCleanupParser();
}
void XMLSerializer::restore_snapshot(const Glib::ustring& filename, History& hist) throw(SerializerError)
void XMLSerializer::restore_snapshot(const Glib::ustring& filename, History& hist)
{
// TODO - all to do!!
// DEBUG - remove me when finished
@ -82,7 +82,7 @@ void XMLSerializer::restore_snapshot(const Glib::ustring& filename, History& his
* build an XML tree from a the file;
*/
doc = xmlParseFile(filename.c_str());
if (doc == NULL)
if (doc == nullptr)
{
xmlCleanupParser();
throw SerializerError("Parsing Error: doc is invalid.");
@ -127,7 +127,7 @@ const Glib::ustring XMLSerializer::get_filename_description()
void XMLSerializer::fill_doc(xmlDocPtr doc, const History& hist)
{
xmlNodePtr root_node = NULL;/* node pointers */
xmlNodePtr root_node = nullptr;/* node pointers */
/*
* Creates a new document, a node and set it as a root node
*/
@ -137,7 +137,7 @@ void XMLSerializer::fill_doc(xmlDocPtr doc, const History& hist)
/*
* Creates a DTD declaration. Isn't mandatory.
*/
/* xmlDtdPtr dtd = */ xmlCreateIntSubset(doc, (const xmlChar *) "sgpem", NULL, (const xmlChar *) "sgpem.dtd");
/* xmlDtdPtr dtd = */ xmlCreateIntSubset(doc, (const xmlChar *) "sgpem", nullptr, (const xmlChar *) "sgpem.dtd");
//TODO: check for DTD compliance??
@ -146,14 +146,14 @@ void XMLSerializer::fill_doc(xmlDocPtr doc, const History& hist)
}
void XMLSerializer::read_doc(xmlDocPtr doc, XMLSerializerFactory& fact) throw(SerializerError)
void XMLSerializer::read_doc(xmlDocPtr doc, XMLSerializerFactory& fact)
{
/*
* Check the document is of the right kind
*/
xmlNodePtr root;
root = xmlDocGetRootElement(doc);
if (root == NULL)
if (root == nullptr)
{
xmlFreeDoc(doc);
xmlCleanupParser();
@ -162,7 +162,7 @@ void XMLSerializer::read_doc(xmlDocPtr doc, XMLSerializerFactory& fact) throw(Se
xmlNodePtr cur;
cur = root->children;
while (cur != NULL)
while (cur != nullptr)
{
Glib::ustring name((const char *)cur->name);
if (name == "resources")
@ -179,17 +179,17 @@ void XMLSerializer::read_doc(xmlDocPtr doc, XMLSerializerFactory& fact) throw(Se
XMLSerializerFactory::Parameters* read_properties(xmlAttrPtr prop)
{
if (prop == NULL)
return NULL;
if (prop == nullptr)
return nullptr;
XMLSerializerFactory::Parameters* par = new XMLSerializerFactory::Parameters();
while (prop != NULL)
while (prop != nullptr)
{
if (prop->children && xmlNodeIsText(prop->children))
{
xmlChar *key = xmlNodeGetContent (prop->children);
// xmlChar *key = xmlNodeListGetString(doc, prop->children, 1);
if (key != NULL)
if (key != nullptr)
{
std::pair<Glib::ustring, Glib::ustring> key_value(Glib::ustring((const char *)prop->name), Glib::ustring((const char *)key));
par->insert(key_value);
@ -205,14 +205,14 @@ void XMLSerializer::read_resources(xmlNodePtr resources_node, XMLSerializerFacto
{
xmlNodePtr cur;
cur = resources_node->children;
while (cur != NULL)
while (cur != nullptr)
{
Glib::ustring node_name((const char *)cur->name);
if (node_name == "resource")
{
xmlAttrPtr prop = cur->properties;
XMLSerializerFactory::Parameters* par = read_properties(prop);
if (par != NULL)
if (par != nullptr)
{
fact.factory_method(Glib::ustring("Resource"), *par);
}
@ -224,19 +224,19 @@ void XMLSerializer::read_resources(xmlNodePtr resources_node, XMLSerializerFacto
}
void XMLSerializer::read_schedulables(xmlNodePtr schedulables_node, XMLSerializerFactory& fact)
{
if (schedulables_node == NULL)
if (schedulables_node == nullptr)
return;
xmlNodePtr cur;
cur = schedulables_node->children;
while (cur != NULL)
while (cur != nullptr)
{
Glib::ustring node_name((const char *)cur->name);
if (node_name == "process")
{
xmlAttrPtr prop = cur->properties;
XMLSerializerFactory::Parameters* par = read_properties(prop);
if (par != NULL)
if (par != nullptr)
{
fact.factory_method(Glib::ustring("Process"), *par);
}
@ -250,19 +250,19 @@ void XMLSerializer::read_schedulables(xmlNodePtr schedulables_node, XMLSerialize
void XMLSerializer::read_threads(xmlNodePtr threads_node, XMLSerializerFactory& fact)
{
if (threads_node == NULL)
if (threads_node == nullptr)
return;
xmlNodePtr cur;
cur = threads_node->children;
while (cur != NULL)
while (cur != nullptr)
{
Glib::ustring node_name((const char *)cur->name);
if (node_name == "thread")
{
xmlAttrPtr prop = cur->properties;
XMLSerializerFactory::Parameters* par = read_properties(prop);
if (par != NULL)
if (par != nullptr)
{
fact.factory_method(Glib::ustring("Thread"), *par);
}
@ -276,21 +276,21 @@ void XMLSerializer::read_threads(xmlNodePtr threads_node, XMLSerializerFactory&
void XMLSerializer::read_requests(xmlNodePtr requests_node, XMLSerializerFactory& fact)
{
if (requests_node == NULL)
if (requests_node == nullptr)
{
return;
}
xmlNodePtr cur;
cur = requests_node->children;
while (cur != NULL)
while (cur != nullptr)
{
Glib::ustring node_name((const char *)cur->name);
if (node_name == "request")
{
xmlAttrPtr prop = cur->properties;
XMLSerializerFactory::Parameters* par = read_properties(prop);
if (par != NULL)
if (par != nullptr)
{
fact.factory_method(Glib::ustring("Request"), *par);
}
@ -304,21 +304,21 @@ void XMLSerializer::read_requests(xmlNodePtr requests_node, XMLSerializerFactory
void XMLSerializer::read_subrequests(xmlNodePtr subrequest_node, XMLSerializerFactory& fact)
{
if (subrequest_node == NULL)
if (subrequest_node == nullptr)
{
return;
}
xmlNodePtr cur;
cur = subrequest_node;
while (cur != NULL)
while (cur != nullptr)
{
Glib::ustring node_name((const char *)cur->name);
if (node_name == "subrequest")
{
xmlAttrPtr prop = cur->properties;
XMLSerializerFactory::Parameters* par = read_properties(prop);
if (par != NULL)
if (par != nullptr)
{
fact.factory_method(Glib::ustring("SubRequest"), *par);
}

View file

@ -61,7 +61,7 @@ namespace sgpem
\throws backend::SerializerError on error
*/
virtual void save_snapshot(const Glib::ustring& filename, const History& hist) throw(SerializerError);
virtual void save_snapshot(const Glib::ustring& filename, const History& hist);
/**
\brief Re-initialize system status from a saved XML snapshot
@ -72,7 +72,7 @@ namespace sgpem
\throws backend::SerializerError
*/
virtual void restore_snapshot(const Glib::ustring& filename, History& hist) throw(SerializerError);
virtual void restore_snapshot(const Glib::ustring& filename, History& hist);
/**
\return Constant string "xsgp"
@ -99,7 +99,7 @@ namespace sgpem
Traverse the passed (previously readed) xml document and
rebuild the correct image using the XMLSerializerFactory object.
*/
void read_doc(xmlDocPtr doc, XMLSerializerFactory& fact) throw(SerializerError);
void read_doc(xmlDocPtr doc, XMLSerializerFactory& fact);
/**
\brief Restore all the resources from the passed xml node

View file

@ -47,7 +47,7 @@ History* XMLSerializerFactory::get_history()
}
void
XMLSerializerFactory::factory_method(const Glib::ustring& class_name, Parameters& parameters) throw(SerializerError)
XMLSerializerFactory::factory_method(const Glib::ustring& class_name, Parameters& parameters)
{
if (class_name == "Resource")
{

View file

@ -77,7 +77,7 @@ namespace sgpem
\throw SerializerError If not all necessary parameters for an object creation are provided
*/
void factory_method(const Glib::ustring& class_name, Parameters& parameters) throw(SerializerError);
void factory_method(const Glib::ustring& class_name, Parameters& parameters);
protected:
private:
typedef Environment::resource_key_t resource_key_t;

View file

@ -44,7 +44,7 @@ XMLVisitor::~XMLVisitor()
{
}
void XMLVisitor::from_resource(const Resource& /*obj*/) throw(SerializerError)
void XMLVisitor::from_resource(const Resource& /*obj*/)
{
throw SerializerError(
_("XMLVisitor: unsupported method from_resource(const Resource& obj)")
@ -52,50 +52,50 @@ void XMLVisitor::from_resource(const Resource& /*obj*/) throw(SerializerError)
}
void XMLVisitor::from_history(const History& obj) throw(SerializerError)
void XMLVisitor::from_history(const History& obj)
{
from_history(_current, obj);
}
void XMLVisitor::from_environment(const Environment& obj) throw(SerializerError)
void XMLVisitor::from_environment(const Environment& obj)
{
from_environment(_current, obj);
}
void XMLVisitor::from_process(const Process& obj) throw(SerializerError)
void XMLVisitor::from_process(const Process& obj)
{
from_process(_current, obj);
}
void XMLVisitor::from_thread(const Thread& obj) throw(SerializerError)
void XMLVisitor::from_thread(const Thread& obj)
{
from_thread(_current, obj);
}
void XMLVisitor::from_request(const Request& obj) throw(SerializerError)
void XMLVisitor::from_request(const Request& obj)
{
from_request(_current, obj);
}
void XMLVisitor::from_subrequest(const SubRequest& obj) throw(SerializerError)
void XMLVisitor::from_subrequest(const SubRequest& obj)
{
from_subrequest(_current, obj);
}
void XMLVisitor::from_resource(const Resource& obj, const Glib::ustring& key) throw(SerializerError)
void XMLVisitor::from_resource(const Resource& obj, const Glib::ustring& key)
{
from_resource(_current, obj, key);
}
void XMLVisitor::from_history(xmlNodePtr parent, const History& hist) throw(SerializerError)
void XMLVisitor::from_history(xmlNodePtr parent, const History& hist)
{
if (parent != NULL)
if (parent != nullptr)
{
from_environment(parent, hist.get_last_environment());
}
@ -106,9 +106,9 @@ void XMLVisitor::from_history(xmlNodePtr parent, const History& hist) throw(Seri
}
void XMLVisitor::from_environment(xmlNodePtr parent, const Environment& env) throw(SerializerError)
void XMLVisitor::from_environment(xmlNodePtr parent, const Environment& env)
{
if (parent == NULL)
if (parent == nullptr)
{
throw SerializerError(_("Error trying to add data to empty XML node."));
}
@ -116,7 +116,7 @@ void XMLVisitor::from_environment(xmlNodePtr parent, const Environment& env) thr
//Enclosing block - save resources
//
{
xmlNodePtr resources_node = xmlNewChild(parent, NULL, (const xmlChar *) "resources", NULL);
xmlNodePtr resources_node = xmlNewChild(parent, nullptr, (const xmlChar *) "resources", nullptr);
const Environment::Resources& rvect = env.get_resources();
typedef Environment::Resources::const_iterator res_iterator;
@ -136,7 +136,7 @@ void XMLVisitor::from_environment(xmlNodePtr parent, const Environment& env) thr
//Enclosing block - save schedulables
//
{
xmlNodePtr schedulables_node = xmlNewChild(parent, NULL, (const xmlChar *) "schedulables", NULL);
xmlNodePtr schedulables_node = xmlNewChild(parent, nullptr, (const xmlChar *) "schedulables", nullptr);
const Environment::Processes& pvect = env.get_processes();
typedef std::vector<Process*>::const_iterator proc_iterator;
@ -153,9 +153,9 @@ void XMLVisitor::from_environment(xmlNodePtr parent, const Environment& env) thr
}
void XMLVisitor::from_resource(xmlNodePtr parent, const Resource& obj, const Glib::ustring& key) throw(SerializerError)
void XMLVisitor::from_resource(xmlNodePtr parent, const Resource& obj, const Glib::ustring& key)
{
if (parent != NULL)
if (parent != nullptr)
{
Glib::ustring id = "reskey" + key;
Glib::ustring strPreemptible("false"); // fixed??
@ -163,7 +163,7 @@ void XMLVisitor::from_resource(xmlNodePtr parent, const Resource& obj, const Gli
Glib::ustring strPlaces;
to_string<int>(static_cast<int>(obj.get_places()), strPlaces);
xmlNodePtr process_node = xmlNewChild(parent, NULL, (const xmlChar *) "resource", NULL);
xmlNodePtr process_node = xmlNewChild(parent, nullptr, (const xmlChar *) "resource", nullptr);
xmlNewProp(process_node, (const xmlChar *) "name", (const xmlChar *) obj.get_name().c_str());
xmlNewProp(process_node, (const xmlChar *) "id", (const xmlChar *) id.c_str());
xmlNewProp(process_node, (const xmlChar *) "arrival-time", (const xmlChar *) strArrivalTime.c_str());
@ -177,22 +177,22 @@ void XMLVisitor::from_resource(xmlNodePtr parent, const Resource& obj, const Gli
}
void XMLVisitor::from_process(xmlNodePtr parent, const Process& obj) throw(SerializerError)
void XMLVisitor::from_process(xmlNodePtr parent, const Process& obj)
{
if (parent != NULL)
if (parent != nullptr)
{
Glib::ustring strPriority;
Glib::ustring strArrivalTime;
to_string<int>(obj.get_base_priority(), strPriority);
to_string<int>(obj.get_arrival_time(), strArrivalTime);
xmlNodePtr process_node = xmlNewChild(parent, NULL, (const xmlChar *) "process", NULL);
xmlNodePtr process_node = xmlNewChild(parent, nullptr, (const xmlChar *) "process", nullptr);
xmlNewProp(process_node, (const xmlChar *) "name", (const xmlChar *) obj.get_name().c_str());
xmlNewProp(process_node, (const xmlChar *) "priority", (const xmlChar *) strPriority.c_str());
xmlNewProp(process_node, (const xmlChar *) "arrival-time", (const xmlChar *) strArrivalTime.c_str());
// make a threads subnode
xmlNodePtr threads_node = xmlNewChild(process_node, NULL, (const xmlChar *) "threads", NULL);
xmlNodePtr threads_node = xmlNewChild(process_node, nullptr, (const xmlChar *) "threads", nullptr);
// iterate on threads
typedef std::vector<Thread*> Threads;
@ -214,9 +214,9 @@ void XMLVisitor::from_process(xmlNodePtr parent, const Process& obj) throw(Seria
}
void XMLVisitor::from_thread(xmlNodePtr parent, const Thread& obj) throw(SerializerError)
void XMLVisitor::from_thread(xmlNodePtr parent, const Thread& obj)
{
if (parent != NULL)
if (parent != nullptr)
{
Glib::ustring strPriority;
@ -226,14 +226,14 @@ void XMLVisitor::from_thread(xmlNodePtr parent, const Thread& obj) throw(Seriali
to_string<int>(obj.get_arrival_time(), strArrivalTime);
to_string<int>(obj.get_total_cpu_time(), strLastsTime);
xmlNodePtr thread_node = xmlNewChild(parent, NULL, (const xmlChar *) "thread", NULL);
xmlNodePtr thread_node = xmlNewChild(parent, nullptr, (const xmlChar *) "thread", nullptr);
xmlNewProp(thread_node, (const xmlChar *) "name", (const xmlChar *) obj.get_name().c_str());
xmlNewProp(thread_node, (const xmlChar *) "priority", (const xmlChar *) strPriority.c_str());
xmlNewProp(thread_node, (const xmlChar *) "arrival-delta", (const xmlChar *) strArrivalTime.c_str());
xmlNewProp(thread_node, (const xmlChar *) "lasts-for", (const xmlChar *) strLastsTime.c_str());
// make a requests subnode
xmlNodePtr requests_node = xmlNewChild(thread_node, NULL, (const xmlChar *) "requests", NULL);
xmlNodePtr requests_node = xmlNewChild(thread_node, nullptr, (const xmlChar *) "requests", nullptr);
// iterate on requests
typedef std::vector<Request*> Requests;
typedef std::vector<Request*>::const_iterator req_iterator;
@ -254,19 +254,19 @@ void XMLVisitor::from_thread(xmlNodePtr parent, const Thread& obj) throw(Seriali
}
void XMLVisitor::from_request(xmlNodePtr parent, const Request& obj) throw(SerializerError)
void XMLVisitor::from_request(xmlNodePtr parent, const Request& obj)
{
if (parent != NULL)
if (parent != nullptr)
{
Glib::ustring strArrivalTime;
to_string<int>(obj.get_instant(), strArrivalTime);
xmlNodePtr request_node = xmlNewChild(parent, NULL, (const xmlChar *) "request", NULL);
xmlNodePtr request_node = xmlNewChild(parent, nullptr, (const xmlChar *) "request", nullptr);
xmlNewProp(request_node, (const xmlChar *) "arrival-time", (const xmlChar *) strArrivalTime.c_str());
// make a requests subnode
// xmlNodePtr subrequests_node = xmlNewChild(thread_node, NULL, (const xmlChar *) "requests", NULL);
// xmlNodePtr subrequests_node = xmlNewChild(thread_node, nullptr, (const xmlChar *) "requests", nullptr);
// iterate on subrequests
typedef std::vector<SubRequest*> SubRequests;
typedef std::vector<SubRequest*>::const_iterator subreq_iterator;
@ -287,9 +287,9 @@ void XMLVisitor::from_request(xmlNodePtr parent, const Request& obj) throw(Seria
}
void XMLVisitor::from_subrequest(xmlNodePtr parent, const SubRequest& obj) throw(SerializerError)
void XMLVisitor::from_subrequest(xmlNodePtr parent, const SubRequest& obj)
{
if (parent != NULL)
if (parent != nullptr)
{
Glib::ustring strResource;
@ -297,7 +297,7 @@ void XMLVisitor::from_subrequest(xmlNodePtr parent, const SubRequest& obj) throw
to_string<int>(obj.get_resource_key(), strResource);
to_string<int>(obj.get_length(), strLastsFor);
xmlNodePtr subrequest_node = xmlNewChild(parent, NULL, (const xmlChar *) "subrequest", NULL);
xmlNodePtr subrequest_node = xmlNewChild(parent, nullptr, (const xmlChar *) "subrequest", nullptr);
xmlNewProp(subrequest_node, (const xmlChar *) "resource", (const xmlChar *) strResource.c_str());
xmlNewProp(subrequest_node, (const xmlChar *) "lasts-for", (const xmlChar *) strLastsFor.c_str());
}

View file

@ -69,61 +69,61 @@ namespace sgpem
\brief Add output to the serializer taking data from history
Wrapper method: call from_history(xmlNodePtr parent, const History& obj);
*/
virtual void from_history(const History& obj) throw(SerializerError);
virtual void from_history(const History& obj);
/**
\brief Add output to the serializer taking data from environment
Wrapper method: call from_environment(xmlNodePtr parent, const Environment& obj);
*/
virtual void from_environment(const Environment& obj) throw(SerializerError);
virtual void from_environment(const Environment& obj);
/**
\brief Add output to the serializer taking data from resource
BUG: a resource must be saved with her own associated key.
Throw an exception.
*/
virtual void from_resource(const Resource& obj) throw(SerializerError);
virtual void from_resource(const Resource& obj);
/**
\brief Add output to the serializer taking data from resource and key
BUG FIXED: This save a resource with her own associated key.
Wrapper method: call from_resource(xmlNodePtr parent, const Resource& obj, const Glib::ustring& key);
*/
virtual void from_resource(const Resource& obj, const Glib::ustring& key) throw(SerializerError);
virtual void from_resource(const Resource& obj, const Glib::ustring& key);
/**
\brief Add output to the serializer taking data from process
Wrapper method: call from_process(xmlNodePtr parent, const Process& obj);
*/
virtual void from_process(const Process& obj) throw(SerializerError);
virtual void from_process(const Process& obj);
/**
\brief Add output to the serializer taking data from thread
Wrapper method: call from_thread(xmlNodePtr parent, const Thread& obj);
*/
virtual void from_thread(const Thread& obj) throw(SerializerError);
virtual void from_thread(const Thread& obj);
/**
\brief Add output to the serializer taking data from request
Wrapper method: call from_request(xmlNodePtr parent, const Request& obj);
*/
virtual void from_request(const Request& obj) throw(SerializerError);
virtual void from_request(const Request& obj);
/**
\brief Add output to the serializer taking data from subrequest
Wrapper method: call from_subrequest(xmlNodePtr parent, const SubRequest& obj);
*/
virtual void from_subrequest(const SubRequest& obj) throw(SerializerError);
virtual void from_subrequest(const SubRequest& obj);
private:
void from_history(xmlNodePtr parent, const History& obj) throw(SerializerError);
void from_environment(xmlNodePtr parent, const Environment& obj) throw(SerializerError);
void from_resource(xmlNodePtr parent, const Resource& obj, const Glib::ustring& key) throw(SerializerError);
void from_process(xmlNodePtr parent, const Process& obj) throw(SerializerError);
void from_thread(xmlNodePtr parent, const Thread& obj) throw(SerializerError);
void from_request(xmlNodePtr parent, const Request& obj) throw(SerializerError);
void from_subrequest(xmlNodePtr parent, const SubRequest& obj) throw(SerializerError);
void from_history(xmlNodePtr parent, const History& obj);
void from_environment(xmlNodePtr parent, const Environment& obj);
void from_resource(xmlNodePtr parent, const Resource& obj, const Glib::ustring& key);
void from_process(xmlNodePtr parent, const Process& obj);
void from_thread(xmlNodePtr parent, const Thread& obj);
void from_request(xmlNodePtr parent, const Request& obj);
void from_subrequest(xmlNodePtr parent, const SubRequest& obj);
xmlNodePtr _current;
};