The brackets define the function...
for example, with:
int main ()
{
<stuff for the function main goes here>
}
A couple questions to seasoned c coders (I'm a bit rusty myself) - should there be a semicolon after the int main statement (I don't think...) aaaand do the parentheses on int main define what can be passed to other programs (global/local)?
I like doing 3d animations with Pov-Ray ( www.povray.org ) which uses a C-ish language to define objects...it's really worth checking out.
Marks256 said:So, if someone would answer my erlier; "Is C just Assembly on steroids?".
_nox_ said:lol. Tell me, what's so complicated with C/C++ ?
It's the simplest language I've ever been faced with...
Nigel Goodwin said:It's all down to what you're used to, as a BASIC/Pascal/Assembler programmer I find C horrible and very hard to read - and all those curly brackets drive me MAD!
ApochPiQ said:Urgh. C++ is the most vile and ugly language ever to curse the world. C is clean and elegant - it's a beautiful enough language for what it was meant to accomplish originally - but it just doesn't have the tools of abstraction needed for most modern software development.
Now if MCUs started supporting ML or Lisp dialects, I'd be in heaven.
_nox_ said:Show me the "ugly" points - I don't see them.
Yes - So please show me the ugly points ...Nigel Goodwin said:Everyone else does! - what you're saying is that your personal preference is for C/C++ - and that's all it is, YOUR personal preference.
_nox_ said:Yes - So please show me the ugly points ...And stay cool.
/**
* @(#) core.hpp
*/
#pragma once
#ifndef core_hpp_h
#define core_hpp_h
#include "task.hpp"
#include "../globdefs.hpp"
/**
* Main System Namespace
*/
namespace _msys
{
/**
* Core class.
* $Description:
* - Heart of the application. Manages the tasks and events.
* - Takes care of memory
* - Handles the errors
* - and so on
*/
class core
{
public:
/**
* Constructor
*/
core( );
/**
* Destructor
*/
virtual ~core( );
void execute( ); /* Executes the core. */
void add_task( IN _aux::mem_pointer< task > & ); /* Adds a task to the core */
void kill_tasks( ); /* Kills all tasks. */
void remove_task( IN _aux::mem_pointer< task > & ); /* Removes task from the core */
void shut_down( ); /* Shuts the application down */
/**
* Get active task list size ( for application : class )
*/
size_t get_alist_size( ) const;
private:
/**
* Lists all paused tasks. || Info: Another way to
* to do this, would be a bIsPaused pointer. But I
* assume this a much faster way to perform task pausing.
*/
std::list< _aux::mem_pointer< task > > paused_task_list;
/**
* List of active tasks
*/
std::list< _aux::mem_pointer< task > > task_list;
};
}
#endif
/**
* @(#) core.cpp
*/
#include "core.hpp"
using namespace _msys;
/**
* Constructor
*/
core::core( )
{
}
/**
* Destructor
*/
core::~core( )
{
}
/**
* Shuts the application down
*/
void core::shut_down( )
{
kill_tasks();
}
/**
* Executes the core.
*/
void core::execute( )
{
std::list< _aux::mem_pointer< task > >::iterator it; /* Define iterator */
for( it = task_list.begin( ); it != task_list.end( ); ) /* Run through all tasks inside the active */
/* task list */
{
task *_t = NULL;
_t = ( *it );
++it;
if( !_t->bCanKill ) /* If task shall stay active, update it */
{
/*
* Update task.
*/
_t->update( );
}
}
/*
* Loop again to remove dead tasks.
*/
for( it = task_list.begin( ); it != task_list.end( ); ) /* Run through all tasks inside the active */
/* task list and check whether they shall */
/* be removed. */
{
task *_t = NULL;
_t = ( *it );
++it;
if( _t->bCanKill ) /* If task shall be removed , move it to the paused task list */
{
_t->stop( ); /* Call stop-procedure of task */
/*
* Remove task from active list and set it to zero
*/
task_list.remove( _t );
_t = NULL;
}
}
/*
* Call garbage collection function
* from memory managment object
*/
_aux::mem_object::collect_garbage();
}
/**
* Adds a task to the core
*/
void core::add_task( IN _aux::mem_pointer< task > &_t )
{
/*
* Execute task immediately ( Errors are captured by exception handling )
*/
_t->start( );
std::list< _aux::mem_pointer< task > >::iterator it; /* Define iterator */
/*
* Keep the order of priorities straight.
*/
for( it = task_list.begin( ); it != task_list.end( ); ++it )
{
_aux::mem_pointer< task > &_comp = ( *it );
if( _comp->lPriority > _t->lPriority )
{
break;
}
}
task_list.insert( it, _t );
}
/**
* Kills all tasks
*/
void core::kill_tasks( )
{
/*
* Run through each task and set its kill flag to true
*/
for( std::list< _aux::mem_pointer< task > >::iterator it = task_list.begin( );
it != task_list.end( ); ++it )
{
( *it )->bCanKill = true;
}
}
/**
* Removes task from the core
*/
void core::remove_task( IN _aux::mem_pointer< task > &_t )
{
}
/**
* Get active task list size ( for application : class )
*/
size_t core::get_alist_size( ) const
{
return task_list.size();
}
/**
* @(#) gui_control.hpp
*/
#pragma once
#ifndef gui_control_hpp_h
#define gui_control_hpp_h
#include "../task.hpp"
#include "layout.hpp"
/**
* Context includes
*/
#include "../opengl_context.hpp"
#include "../gdiplus_context.hpp"
#include "../audio_context.hpp"
#include "../input_context.hpp"
/**
* Control includes
*/
#include "../_cli/cli_control.hpp"
/**
* Main System Namespace
*/
namespace _msys
{
/**
* Contains everything necessary for GUI managment
*/
namespace _gui
{
/**
* Main GUI managment class
*/
class gui_control: public task
{
public:
gui_control( );
virtual ~gui_control( );
/**
* Add layout
*/
void add_layout( IN layout );
/**
* Switch layout
*/
void switch_layout( );
/**
* render the gui
*/
void render( );
/**
* Connect the Input/Audio and Graphics interfaces
*/
void connect_input( IN _aux::mem_pointer< input_context >& );
void connect_gdiplus( IN _aux::mem_pointer< gdiplus_context >& );
void connect_opengl( IN _aux::mem_pointer< opengl_context >& );
void connect_audio( IN _aux::mem_pointer< audio_context >& );
/**
* Connect CLI Control
*/
void connect_clicontrol( IN _aux::mem_pointer< _cli::cli_control >& );
/*-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-*/
virtual void start( ); /* Executes the task */
virtual void stop( ); /* Stops this task */
virtual void sleep( IN const unsigned int ); /* Stops the task for a specified time interval */
virtual void reset( ); /* Resets the task */
virtual void update( ); /* Updates the task */
virtual void perform_event( IN event* ); /* Lets the task perform an event */
/**
* Realization of a function in mem_object
*/
virtual unsigned long size();
private:
/**
* Class describing the gui-layout ( list of various layouts which can be switched )
*/
std::vector< layout > layout_list;
/**
* Contexts ( OpenGL -> 2D/3D Graphics, GDI+ -> 2D Graphics, DSound -> Audio, HID/DInput -> Human Interface Devices )
*/
_aux::mem_pointer< _msys::opengl_context > spOpenGLContext;
_aux::mem_pointer< _msys::gdiplus_context > spGDIPlusContext;
_aux::mem_pointer< _msys::audio_context > spAudioContext;
_aux::mem_pointer< _msys::input_context > spInputContext;
/**
* CLI-Control
*/
_aux::mem_pointer< _cli::cli_control > spCLIControl;
};
}
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?