- Pretty-indenting code

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@674 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-06-29 08:44:30 +00:00
parent 7aecc910ba
commit 6b27a8461b
94 changed files with 3073 additions and 3066 deletions

11
config/indenter Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
#find . -name "*.cc" -or -name "*.hh" -or -name "*.tcc" | \
# xargs indent -v -sc -psl -bls -bad -bap -bbb -nsob \
# -bli0 -cli0 -cbi0 -npcs -cs -nsaf -nsai -nsaw \
# -nprs -i2 -lp -ppi2 -l80 -nbbo -hnl -ss -di8 -nbc
find . -name "*.cc" -or -name "*.hh" -or -name "*.tcc" | \
xargs astyle --style=ansi -s2 -b -N -L -p -O -V \
--mode=c

View File

@ -33,7 +33,8 @@
#include "config.h" #include "config.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C"
{
#endif #endif
#define SG_CONSTRUCTOR __attribute__ ((constructor)) #define SG_CONSTRUCTOR __attribute__ ((constructor))

View File

@ -39,28 +39,33 @@
// FIXME: Eeeeh? Why does this work without explicit namespace resolving? // FIXME: Eeeeh? Why does this work without explicit namespace resolving?
// Is there some using declaration in included HEADERS?? Aaaaagh! // Is there some using declaration in included HEADERS?? Aaaaagh!
class TestPythonPolicyManager : public PythonPolicyManager { class TestPythonPolicyManager : public PythonPolicyManager
{
public: public:
void test_init(const char* policy_name) { void test_init(const char* policy_name)
{
init(); init();
_python_policy = new PythonPolicy(policy_name); _python_policy = new PythonPolicy(policy_name);
} }
Policy& get_policy() { Policy& get_policy()
{
return *_python_policy; return *_python_policy;
} }
}; };
int int
main(int argc, char** argv) { main(int argc, char** argv)
{
using namespace sgpem; using namespace sgpem;
using namespace std; using namespace std;
int successes = 0; int successes = 0;
if(argc != 2) { if(argc != 2)
{
std::cout << "[EE] Usage:\n\t" << argv[0] << std::cout << "[EE] Usage:\n\t" << argv[0] <<
" path/to/uninstalled/policies" << std::endl; " path/to/uninstalled/policies" << std::endl;
exit(-1); exit(-1);

View File

@ -29,7 +29,8 @@
therein. See "info libtool": "dlopened modules" therein. See "info libtool": "dlopened modules"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C"
{
#endif #endif
#include "config.h" #include "config.h"
@ -38,12 +39,10 @@ extern "C" {
#define SG_DESTRUCTOR __attribute__ ((destructor)) #define SG_DESTRUCTOR __attribute__ ((destructor))
void SG_DLLEXPORT SG_CONSTRUCTOR hook_ctor(void) void SG_DLLEXPORT SG_CONSTRUCTOR hook_ctor(void)
{ {}
}
void SG_DLLEXPORT SG_DESTRUCTOR hook_dtor(void) void SG_DLLEXPORT SG_DESTRUCTOR hook_dtor(void)
{ {}
}
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -30,8 +30,7 @@ using std::vector;
DynamicProcess::DynamicProcess(StaticProcess* core) : DynamicProcess::DynamicProcess(StaticProcess* core) :
DynamicSchedulable(*core) DynamicSchedulable(*core)
{ {}
}
DynamicProcess::DynamicProcess(const DynamicProcess &other) : DynamicProcess::DynamicProcess(const DynamicProcess &other) :
Schedulable(), DynamicSchedulable(other), Process() Schedulable(), DynamicSchedulable(other), Process()
@ -85,7 +84,8 @@ DynamicProcess::get_state() const
// TODO Is this OK? Must be tested... // TODO Is this OK? Must be tested...
switch(thread_state) { switch(thread_state)
{
case state_running: // (a) case state_running: // (a)
return state_running; return state_running;
case state_ready: // (b) case state_ready: // (b)

View File

@ -27,8 +27,7 @@ using namespace sgpem;
DynamicResource::DynamicResource(StaticResource *core) : DynamicResource::DynamicResource(StaticResource *core) :
_static_resource(core) _static_resource(core)
{ {}
}
Glib::ustring Glib::ustring
DynamicResource::get_name() const DynamicResource::get_name() const

View File

@ -29,8 +29,7 @@ DynamicSchedulable::DynamicSchedulable(StaticSchedulable& obj) :
_time_left(obj.get_total_cpu_time()), _ref(&obj), _last_acquisition(-1), _time_left(obj.get_total_cpu_time()), _ref(&obj), _last_acquisition(-1),
_last_release(-1), _priority_push(0), _last(-1), _last_release(-1), _priority_push(0), _last(-1),
_my_state(state_future) _my_state(state_future)
{ {}
}
bool bool
DynamicSchedulable::operator==(const DynamicSchedulable& dx) const DynamicSchedulable::operator==(const DynamicSchedulable& dx) const

View File

@ -112,8 +112,7 @@ namespace sgpem
void set_state(state s); void set_state(state s);
void serialize(SerializeVisitor& translator) const void serialize(SerializeVisitor& translator) const
{ {}
}
/** \brief Returns a pointer to the schedulable object /** \brief Returns a pointer to the schedulable object
* *

View File

@ -31,8 +31,7 @@ using std::vector;
DynamicThread::DynamicThread(StaticThread* core, DynamicProcess* parent) : DynamicThread::DynamicThread(StaticThread* core, DynamicProcess* parent) :
DynamicSchedulable(*core), _state(state_future), _parent(parent) DynamicSchedulable(*core), _state(state_future), _parent(parent)
{ {}
}
DynamicThread::DynamicThread(const DynamicThread &other) : DynamicThread::DynamicThread(const DynamicThread &other) :
Schedulable(), DynamicSchedulable(other), Thread() Schedulable(), DynamicSchedulable(other), Thread()

View File

@ -29,13 +29,15 @@
// Do not include complete template definition here: // Do not include complete template definition here:
#include "singleton.hh" #include "singleton.hh"
namespace sgpem { namespace sgpem
{
class GlobalPreferences; class GlobalPreferences;
} }
#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>;

View File

@ -42,7 +42,8 @@ template class SG_DLLEXPORT smart_ptr<DynamicSchedulable>;
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.
*/ */
History::History() //private constructor. History::History() //private constructor.
:_total_time_elapsed(-1) :
_total_time_elapsed(-1)
{} {}

View File

@ -24,8 +24,7 @@ using namespace sgpem;
ObservedSubject::~ObservedSubject() ObservedSubject::~ObservedSubject()
{ {}
}
/** /**
Calls update() in each Observer Calls update() in each Observer

View File

@ -57,7 +57,8 @@ namespace sgpem
private: private:
SG_DLLLOCAL Plugin(); SG_DLLLOCAL Plugin();
}; //~ class Plugin }
; //~ class Plugin
} //~ namespace sgpem } //~ namespace sgpem

View File

@ -107,8 +107,7 @@ PoliciesGatekeeper::activate_policy(History *history, Policy* policy)
} }
PoliciesGatekeeper::PoliciesGatekeeper() PoliciesGatekeeper::PoliciesGatekeeper()
{ {}
}
void void
PoliciesGatekeeper::deactivate_policies(PolicyManager* manager) PoliciesGatekeeper::deactivate_policies(PolicyManager* manager)

View File

@ -24,8 +24,7 @@ using namespace sgpem;
using namespace memory; using namespace memory;
Policy::~Policy() Policy::~Policy()
{ {}
}
int int
Policy::get_id() const Policy::get_id() const

View File

@ -33,8 +33,7 @@ namespace sgpem
class PolicyParametersException : public std::runtime_error class PolicyParametersException : public std::runtime_error
{ {
public: public:
PolicyParametersException(char* msg): std::runtime_error(msg) {} PolicyParametersException(char* msg): std::runtime_error(msg) {}};
};
class PolicyParameters; class PolicyParameters;

View File

@ -23,6 +23,5 @@
using namespace sgpem; using namespace sgpem;
Process::~Process() Process::~Process()
{ {}
}

View File

@ -23,6 +23,5 @@
using namespace sgpem; using namespace sgpem;
Request::~Request() Request::~Request()
{ {}
}

View File

@ -23,6 +23,5 @@
using namespace sgpem; using namespace sgpem;
Resource::~Resource() Resource::~Resource()
{ {}
}

View File

@ -23,6 +23,5 @@
using namespace sgpem; using namespace sgpem;
Schedulable::~Schedulable() Schedulable::~Schedulable()
{ {}
}

View File

@ -27,8 +27,7 @@ using namespace std;
using namespace memory; using namespace memory;
SchedulableQueue::SchedulableQueue() SchedulableQueue::SchedulableQueue()
{ {}
}
DynamicSchedulable* DynamicSchedulable*
SchedulableQueue::top() SchedulableQueue::top()

View File

@ -25,8 +25,7 @@ using namespace std;
Slice::Slice(const int& start, const int& duration, const SchedulableQueue& status) Slice::Slice(const int& start, const int& duration, const SchedulableQueue& status)
: _ref(status), _started_at(start), _duration(duration) : _ref(status), _started_at(start), _duration(duration)
{ {}
}
const SchedulableQueue* const SchedulableQueue*
Slice::get_simulation_status() const Slice::get_simulation_status() const

View File

@ -24,12 +24,10 @@ using namespace sgpem;
StaticProcess::StaticProcess(const Glib::ustring& name, const unsigned int& arrival, const unsigned int& total, const int& priority) StaticProcess::StaticProcess(const Glib::ustring& name, const unsigned int& arrival, const unsigned int& total, const int& priority)
: StaticSchedulable(name, arrival, total, priority) : StaticSchedulable(name, arrival, total, priority)
{ {}
}
StaticProcess::~StaticProcess() StaticProcess::~StaticProcess()
{ {}
}
Glib::ustring Glib::ustring
StaticProcess::get_type() const StaticProcess::get_type() const

View File

@ -25,8 +25,7 @@ using namespace sgpem;
StaticResource::StaticResource(const Glib::ustring& name, StaticResource::StaticResource(const Glib::ustring& name,
unsigned int places) : unsigned int places) :
_name(name), _places(places) _name(name), _places(places)
{ {}
}
Glib::ustring Glib::ustring
StaticResource::get_name() const StaticResource::get_name() const

View File

@ -27,12 +27,10 @@ StaticSchedulable::StaticSchedulable(const Glib::ustring& name,
const unsigned int& total, const unsigned int& total,
const int& priority) : const int& priority) :
_name(name), _arrival_time(arrival), _total_time(total), _priority(priority) _name(name), _arrival_time(arrival), _total_time(total), _priority(priority)
{ {}
}
StaticSchedulable::~StaticSchedulable() StaticSchedulable::~StaticSchedulable()
{ {}
}
unsigned int unsigned int
StaticSchedulable::get_arrival_time() const StaticSchedulable::get_arrival_time() const

View File

@ -33,8 +33,7 @@ StaticThread::StaticThread(const Glib::ustring& name,
StaticSchedulable(name, arrival_time, 0, base_priority), StaticSchedulable(name, arrival_time, 0, base_priority),
_start_time_delta(arrival_time), _required_cpu_time(0), _start_time_delta(arrival_time), _required_cpu_time(0),
_process(&process) _process(&process)
{ {}
}
unsigned int unsigned int
StaticThread::get_total_cpu_time() const StaticThread::get_total_cpu_time() const

View File

@ -23,6 +23,5 @@
using namespace sgpem; using namespace sgpem;
SubRequest::~SubRequest() SubRequest::~SubRequest()
{ {}
}

View File

@ -23,6 +23,5 @@
using namespace sgpem; using namespace sgpem;
Thread::~Thread() Thread::~Thread()
{ {}
}

View File

@ -29,7 +29,8 @@
#include <stdexcept> #include <stdexcept>
namespace sgpem { namespace sgpem
{
class UserInterruptException; class UserInterruptException;
class SG_DLLEXPORT UserInterruptException : public std::runtime_error class SG_DLLEXPORT UserInterruptException : public std::runtime_error

View File

@ -33,7 +33,8 @@
#include "io_manager.hh" #include "io_manager.hh"
#include "graphical_terminal_io.hh" #include "graphical_terminal_io.hh"
namespace sgpem { namespace sgpem
{
class GraphicalSimulation; class GraphicalSimulation;

View File

@ -36,7 +36,8 @@
#include <memory> #include <memory>
namespace sgpem { namespace sgpem
{
// --------------------------------------------- // ---------------------------------------------

View File

@ -26,7 +26,8 @@
#include <glibmm/ustring.h> #include <glibmm/ustring.h>
namespace sgpem { namespace sgpem
{
class IOManager; class IOManager;

View File

@ -55,7 +55,8 @@ using namespace memory;
using Glib::ustring; using Glib::ustring;
static void load_pyloader_plugin() { static void load_pyloader_plugin()
{
// FIXME: this will need to be moved to an // FIXME: this will need to be moved to an
// appropriate PluginManager class in the backend, // appropriate PluginManager class in the backend,
// and the Makefile fixed accordingly (partly done). // and the Makefile fixed accordingly (partly done).
@ -66,7 +67,8 @@ static void load_pyloader_plugin() {
GlobalPreferences& prefs = GlobalPreferences::get_instance(); GlobalPreferences& prefs = GlobalPreferences::get_instance();
GlobalPreferences::dir_iterator it = prefs.modules_dir_begin(); GlobalPreferences::dir_iterator it = prefs.modules_dir_begin();
while(it != prefs.modules_dir_end()) { while(it != prefs.modules_dir_end())
{
std::string pyloader_path = Module::build_path(*it, "pyloader"); std::string pyloader_path = Module::build_path(*it, "pyloader");
pyloader = new Module(pyloader_path); pyloader = new Module(pyloader_path);
if(*pyloader) break; if(*pyloader) break;

View File

@ -26,7 +26,8 @@
#include <gtkmm/window.h> #include <gtkmm/window.h>
namespace sgpem { namespace sgpem
{
// --------------------------------------------- // ---------------------------------------------

View File

@ -23,10 +23,8 @@
using namespace sgpem; using namespace sgpem;
Observer::Observer() Observer::Observer()
{ {}
}
Observer::~Observer() Observer::~Observer()
{ {}
}

View File

@ -28,8 +28,7 @@ using namespace memory;
using Glib::usleep; using Glib::usleep;
Simulation::Simulation(): _state(state_paused), _mode(true), _timer_interval(1000) Simulation::Simulation(): _state(state_paused), _mode(true), _timer_interval(1000)
{ {}
}
void void
Simulation::set_timer(const int& t) Simulation::set_timer(const int& t)
@ -97,7 +96,8 @@ Simulation::run() throw(UserInterruptException)
if (_mode) if (_mode)
{ {
do { do
{
// chech for termination // chech for termination
bool all_term = true; bool all_term = true;
smart_ptr<SchedulableQueue> left = h.get_simulation_status_at(h.get_current_time()); smart_ptr<SchedulableQueue> left = h.get_simulation_status_at(h.get_current_time());
@ -135,7 +135,8 @@ Simulation::run() throw(UserInterruptException)
if (_state == state_stopped || _state == state_paused) if (_state == state_stopped || _state == state_paused)
return; return;
} while(true); }
while(true);
} }
//******* STEP by STEP //******* STEP by STEP

View File

@ -29,7 +29,8 @@
#include "io_manager.hh" #include "io_manager.hh"
namespace sgpem { namespace sgpem
{
class StandardIO; class StandardIO;

View File

@ -30,8 +30,7 @@ using namespace sgpem;
template<typename T> template<typename T>
PolicyParameters::Parameter<T>::Parameter(Glib::ustring name, const T& value, const T& lower_bound, const T& upper_bound, const bool& required, const T& default_value) PolicyParameters::Parameter<T>::Parameter(Glib::ustring name, const T& value, const T& lower_bound, const T& upper_bound, const bool& required, const T& default_value)
: _name(name), _value(value), _lower_bound(lower_bound), _upper_bound(upper_bound), _is_required(required), _default(default_value) : _name(name), _value(value), _lower_bound(lower_bound), _upper_bound(upper_bound), _is_required(required), _default(default_value)
{ {}
}
template<typename T> template<typename T>
Glib::ustring Glib::ustring

View File

@ -48,7 +48,8 @@ namespace sgpem
private: private:
static Instantiated_class* _instance; static Instantiated_class* _instance;
static Glib::StaticMutex SG_DLLLOCAL _mutex; static Glib::StaticMutex SG_DLLLOCAL _mutex;
}; //~ class Singleton }
; //~ class Singleton
} //~ namespace sgpem } //~ namespace sgpem

View File

@ -20,7 +20,8 @@
#include <new> #include <new>
#include <typeinfo> #include <typeinfo>
namespace memory { namespace memory
{
/** \brief A simple reference counted smart pointer /** \brief A simple reference counted smart pointer
* *
@ -43,7 +44,8 @@ namespace memory {
* from it: its destructor isn't virtual, either. * from it: its destructor isn't virtual, either.
*/ */
template<typename T, bool isArray = false> template<typename T, bool isArray = false>
class smart_ptr { class smart_ptr
{
template<typename T2, bool isArray2> template<typename T2, bool isArray2>
friend class smart_ptr; friend class smart_ptr;
@ -153,10 +155,12 @@ namespace memory {
template<typename U> template<typename U>
smart_ptr(const smart_ptr<U, isArray>& sptr) throw(std::bad_cast); smart_ptr(const smart_ptr<U, isArray>& sptr) throw(std::bad_cast);
struct contents_type { struct contents_type
{
T* ptr; T* ptr;
unsigned int rc; unsigned int rc;
}* _contents; }
* _contents;
}; };
} }

View File

@ -19,7 +19,8 @@
#include "smartp.hh" #include "smartp.hh"
namespace memory { namespace memory
{
template<typename T, bool isArray> template<typename T, bool isArray>
const smart_ptr<T, isArray> smart_ptr<T, isArray>::null = 0; const smart_ptr<T, isArray> smart_ptr<T, isArray>::null = 0;

View File

@ -98,7 +98,8 @@ namespace sgpem
int int
main(int, char**) { main(int, char**)
{
using namespace sgpem; using namespace sgpem;
Scheduler::get_instance(); // Forces initialization of scheduler. Scheduler::get_instance(); // Forces initialization of scheduler.

View File

@ -74,12 +74,10 @@ namespace sgpem
} }
virtual ~Policy() virtual ~Policy()
{ {}
}
virtual void configure() virtual void configure()
{ {}
}
virtual void sort_queue() const throw(UserInterruptException) virtual void sort_queue() const throw(UserInterruptException)
{ // here a lot of fun, exactly O(n^2) fun! { // here a lot of fun, exactly O(n^2) fun!
@ -150,8 +148,7 @@ namespace sgpem
return PRRPolicy.get_instance(); return PRRPolicy.get_instance();
} }
virtual void init() virtual void init()
{ {}
}
static PolicyManager& get_registered_manager(); static PolicyManager& get_registered_manager();
private: private:
@ -217,13 +214,13 @@ namespace sgpem
class StepForwardTester class StepForwardTester
{ {
} }
// from here and further until the bottom, all to throw away I suppose // from here and further until the bottom, all to throw away I suppose
int int
main(int argc, char** argv) { main(int argc, char** argv)
{
using namespace sgpem; using namespace sgpem;
using Glib::Module; using Glib::Module;

View File

@ -34,8 +34,7 @@ using Glib::ustring;
#include "smartp.tcc" #include "smartp.tcc"
TextSimulation::~TextSimulation() TextSimulation::~TextSimulation()
{ {}
}
/** /**
Adds an IO_device and creates a thread which loops the read-parse-execute process Adds an IO_device and creates a thread which loops the read-parse-execute process