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;
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;
};