Commit b51628b2 authored by Mathieu Faverge's avatar Mathieu Faverge
Browse files

Add some comments and fix some alignment

parent b41176d4
......@@ -150,74 +150,83 @@ using namespace std;
*
**********************************/
Core::Core(int &argc, char ** argv){
//bool useGUI;/* if window interface can be displayed */
app=NULL;
coreapp=NULL;
Core::Core(int &argc, char ** argv)
{
/*
* graphic_app is used if a graphical interface is used
* console_app is used if we only care about the console interface
*/
graphic_app = NULL;
console_app = NULL;
/* Qt uses the default system encoding for QString (used when opening a file) */
QTextCodec::setCodecForCStrings(QTextCodec::codecForLocale());
//useGUI = true;
/*
* Store application name and current directory
*/
_run_env[0] = new QString(QDir::currentPath().toStdString().c_str());
_run_env[1] = new QString(argv[0]);
_main_window = NULL;
/* Initialize gloabl variable */
_main_window = NULL;
_render_opengl = NULL;
_trace = NULL;
/* Init of the times */
_time_start = 0;
_time_end = 0;
_trace = NULL;
_is_window_displayed = false;
_is_trace_loaded = false;
_run_env[0] = new QString(QDir::currentPath().toStdString().c_str());
_run_env[1] = new QString(argv[0]);
/* Define the visible interval */
_time_start = 0.;
_time_end = 0.;
Message::set_interface(this);/* define which interface will receive messages */
/* define which interface will receive messages */
/* MathieuTOmyself: No idea what is this */
Message::set_interface(this);
/* Set the options according to the parameters given
* Warning: Work on a copy of argv to keep parameter
* that could be usefull to boost or Qt, as psn
* on Mac for example */
_state = get_state(argc, argv);
#ifdef USE_MPI
boost::mpi::environment env(argc, argv);
#endif
if (_state!= _STATE_SPLITTING && _state!= _STATE_EXPORT_FILE){
app = new QApplication(argc, argv);/* create the Qt application */
/* Create the Qt application */
if ( (_state != _STATE_SPLITTING ) &&
(_state != _STATE_EXPORT_FILE) ) {
graphic_app = new QApplication(argc, argv);
}
else {
console_app = new QCoreApplication(argc, argv);
}
else
coreapp = new QCoreApplication(argc, argv);/* create the Qt application */
/*
* Suppose that no window will be displayed.
*/
_is_window_displayed = false;
/*
* No trace loaded
*/
_is_trace_loaded = false;
/* Start to launch actions */
launch_action(_state, NULL);
}
Core::~Core(){
if(_trace){
if( _trace != NULL )
delete _trace;
}
if (_run_env[0])
if ( _run_env[0] != NULL )
delete _run_env[0];
if (_run_env[1])
if ( _run_env[1] != NULL )
delete _run_env[1];
if (_render_opengl){
if ( _render_opengl != NULL ) {
_render_opengl->release();
delete _render_opengl;
}
/* Qt desallocates _main_window and _render_opengl automatically */
/* Qt desallocates _main_window and _render_opengl automatically */
Message::kill();
if (coreapp!=NULL)delete coreapp;
if (app!=NULL)delete app;
if ( console_app != NULL ) delete console_app;
if ( graphic_app != NULL ) delete graphic_app;
}
......@@ -576,7 +585,7 @@ int Core::run(){
* If a window is displayed, enter in the Qt event loop.
*/
if (_is_window_displayed){
return app->exec();
return graphic_app->exec();
}
else{/* else, quit the application */
return EXIT_SUCCESS;
......
......@@ -80,7 +80,7 @@ class QWaitCondition ;
/*!
*\brief This class is an terminal interface, it inherited from the Interface interface.
*/
class Core : public QObject,public Interface{
class Core : public QObject, public Interface {
Q_OBJECT
public:
......@@ -223,15 +223,16 @@ public:
static const int _STATE_CLEAN_RENDER_AREA = 25;
static const int _STATE_ZOOM_IN_AN_INTERVAL=26;
static const int _STATE_ZOOM_IN_AN_INTERVAL=26;
static const int _STATE_SPLITTING=27;
static const int _STATE_SPLITTING=27;
static const int _LOAD_DATA = 28;
static const int _STATE_SWITCH_CONTAINERS = 29;
static const int _STATE_UPDATE_VARVALUES = 30;
/*!
* \brief Launch an action according to the argument state value.
* \param state An integer corresponding to a kind of action which must be executed.
......@@ -301,12 +302,9 @@ protected:
void* _render;
//Render<Render_opengl>* _render_opengl;
#ifdef USE_MPI
#ifdef USE_MPI
boost::mpi::communicator _world;
#endif
#endif
/*!
* \brief Contains the SVG render instance.
......@@ -316,25 +314,26 @@ protected:
/*!
* \brief Contains the main Qt application instance.
*/
QApplication* app;
QApplication* graphic_app;
/*!
* \brief Contains the main Qt if no interface is loaded
*/
QCoreApplication* coreapp;
QCoreApplication* console_app;
/*!
* \brief Contains the trace instance.
*/
Trace* _trace;
QMutex* _mutex;
Parser *parser;
QWaitCondition * _finished;
QWaitCondition * _closed;
QMutex* _mutex;
Parser* parser;
QWaitCondition* _finished;
QWaitCondition* _closed;
/*!
*\brief This attributes contains the launching current directory (_run_env[0]) and the first argument of the running command (_run_env[1]).
*/
QString* _run_env[2];
QString* _run_env[2];
/*!
*\brief If a file must be opened, this attribute contains its path.
......
......@@ -82,9 +82,8 @@
/*!
*\brief The main function of ViTE.
*/
int main(int argc, char **argv) {
#ifdef VITE_DBG_MEMORY_TRACE
FILE * file;
double timestamp;
......@@ -100,10 +99,10 @@ int main(int argc, char **argv) {
memAllocTrace(file, timestamp, 0);
trace_start(file, timestamp, 0, -1);
#endif /* VITE_DBG_MEMORY_TRACE */
Core console(argc, argv);
console.run();
#ifdef MEMORY_USAGE
#ifdef VITE_DBG_MEMORY_TRACE
trace_finish(file, (clockGet()-timestamp), 0, -1);
......@@ -112,5 +111,6 @@ int main(int argc, char **argv) {
fprintf(stdout, "Max Memory allocated : %ld\n", memAllocGetMax());
fprintf(stdout, "Memory still allocated : %ld\n", memAllocGetCurrent());
#endif
return EXIT_SUCCESS;
}
......@@ -79,10 +79,14 @@ using namespace std;
Container::Container():
_name(), _creation_time(0.0),
_destruction_time(0.0), _type(NULL),
_parent(NULL), _n_states(0),
_state_tree(NULL), _n_events(0),
_name(),
_creation_time(0.0),
_destruction_time(0.0),
_type(NULL),
_parent(NULL),
_n_states(0),
_state_tree(NULL),
_n_events(0),
#ifdef USE_ITC
_events(NULL),
#endif
......
......@@ -132,7 +132,8 @@ void MyDelete(T *ptr){
};
Trace::~Trace() {
Trace::~Trace()
{
//delete _palette;
if(_interval_constrained != NULL) {
......@@ -228,7 +229,7 @@ Container* Trace::create_container(Date &time,
}
if (time > _max_date)
_max_date = time;
_max_date = time;
#if defined(USE_ITC) && defined(BOOST_SERIALIZE)
Serializer<Container>::Instance().setUid(cont);
......@@ -628,16 +629,16 @@ void Trace::set_root_containers(Container::Vector& conts) {
}
void Trace::set_state_types (std::map<Name, StateType* >& conts) {
_state_types=conts;
_state_types=conts;
}
void Trace::set_event_types (std::map<Name, EventType* >& conts) {
_event_types=conts;
_event_types=conts;
}
void Trace::set_link_types (std::map<Name, LinkType* >& conts) {
_link_types=conts;
_link_types=conts;
}
void Trace::set_variable_types (std::map<Name, VariableType* >& conts) {
_variable_types=conts;
_variable_types=conts;
}
void Trace::set_container_types (std::list<ContainerType*>& conts) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment