Merge branch 'edge' into multitool
[clinton/Smoothieware.git] / src / libs / Kernel.h
index 0f08270..8f433d8 100644 (file)
@@ -7,49 +7,40 @@
 
 #ifndef KERNEL_H
 #define KERNEL_H
-#include "libs/Module.h"
-#include "libs/Config.h"
-#include "libs/SlowTicker.h"
-#include "libs/StreamOutputPool.h"
-#include "libs/StepTicker.h"
-#include "libs/Adc.h"
-#include "libs/Digipot.h"
-#include "libs/Pauser.h"
-#include "modules/communication/SerialConsole.h"
-#include "modules/communication/GcodeDispatch.h"
-#include "modules/robot/Planner.h"
-#include "modules/robot/Robot.h"
-#include "modules/robot/Stepper.h"
 
-// See : http://smoothieware.org/listofevents
-#define NUMBER_OF_DEFINED_EVENTS   12
-#define ON_MAIN_LOOP               0
-#define ON_CONSOLE_LINE_RECEIVED   1
-#define ON_GCODE_RECEIVED          2
-#define ON_STEPPER_WAKE_UP         3    //TODO : Remove the need for this event, then this event itself eg: have planner call stepper directly
-#define ON_GCODE_EXECUTE           4
-#define ON_SPEED_CHANGE            5
-#define ON_BLOCK_BEGIN             6
-#define ON_BLOCK_END               7
-#define ON_CONFIG_RELOAD           8
-#define ON_PLAY                    9
-#define ON_PAUSE                   10
-#define ON_IDLE                    11
+#define THEKERNEL Kernel::instance
 
-
-typedef void (Module::*ModuleCallback)(void * argument);
+#include "Module.h"
+#include <array>
+#include <vector>
 
 //Module manager
+class Config;
 class Module;
 class Conveyor;
 class SlowTicker;
+class Pauser;
+class SerialConsole;
+class StreamOutputPool;
+class GcodeDispatch;
+class Robot;
+class Stepper;
+class Planner;
+class ToolsManager;
+class StepTicker;
+class Adc;
+class PublicData;
+
 class Kernel {
     public:
         Kernel();
+        static Kernel* instance; // the Singleton instance of Kernel usable anywhere
+        const char* config_override_filename(){ return "/sd/config-override"; }
+
         void add_module(Module* module);
-        void register_for_event(unsigned int id_event, Module* module);
-        void call_event(unsigned int id_event);
-        void call_event(unsigned int id_event, void * argument);
+        void register_for_event(_EVENT_ENUM id_event, Module* module);
+        void call_event(_EVENT_ENUM id_event);
+        void call_event(_EVENT_ENUM id_event, void * argument);
 
         // These modules are aviable to all other modules
         SerialConsole*    serial;
@@ -60,17 +51,20 @@ class Kernel {
         Stepper*          stepper;
         Planner*          planner;
         Config*           config;
-        Conveyor*           conveyor;
+        Conveyor*         conveyor;
         Pauser*           pauser;
+        ToolManager*     toolmanager;
 
         int debug;
         SlowTicker*       slow_ticker;
         StepTicker*       step_ticker;
         Adc*              adc;
-        Digipot*          digipot;
+        PublicData*       public_data;
+        bool              use_leds;
+        string            current_path;
 
     private:
-        Module* hooks[NUMBER_OF_DEFINED_EVENTS][32]; // When a module asks to be called for a specific event ( a hook ), this is where that request is remembered
+        std::array<std::vector<Module*>, NUMBER_OF_DEFINED_EVENTS> hooks; // When a module asks to be called for a specific event ( a hook ), this is where that request is remembered
 
 };