simelement.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef SIMELEMENT__HPP
  2. #define SIMELEMENT__HPP
  3. #include <fstream>
  4. #include <string>
  5. #include <gsl/gsl_rng.h>
  6. #include "libcsim.hpp"
  7. // forward declarations
  8. class SimLoop;
  9. class Recorder;
  10. class BinRecorder;
  11. class IRngQueue;
  12. using namespace std;
  13. enum SimElementType {NONE, seLayer, seConnection, seLearning, seInput, seNormalize};
  14. static const char* SimElementTypeStrings[6] = {"SimElement", "Layer", "Connection", "Learning", "Input", "Normalize"};
  15. /*! \brief Klasse SimElement
  16. * Basisklasse für Layer-, Connection-, Normalisierungs-Objekte
  17. *
  18. * Detailed description starts here.
  19. */
  20. class SimElement
  21. {
  22. protected:
  23. SimLoop *MainSimLoop; // pointer to SimLoop for getting global settings
  24. int MacroTimeStep; // default: 1000
  25. string DataDirectory;
  26. bool active;
  27. gsl_rng * gslr; // global random generator
  28. IRngQueue * mRndNumQueue; // threaded random number queue
  29. float dt; // time step in ms
  30. Recorder *rec;
  31. BinRecorder *BinRec;
  32. bool resetable;
  33. public:
  34. SimElement(SimLoop* _MainSimLoop, int _MacroTimeStep=1000, SimElementType _type=NONE);
  35. SimElement(SimElementType _type=NONE);
  36. ~SimElement();
  37. string Name;
  38. string SimTag;
  39. SimElementType seType;
  40. string seTypeString;
  41. unsigned int IdNumber;
  42. virtual int proceede(int =0);
  43. virtual int prepare(int =0);
  44. virtual int reset(int t);
  45. virtual long calcMemoryConsumption();
  46. void SetResetable(bool value);
  47. bool Resetable();
  48. int GetMacroTimeStep();
  49. int SetMacroTimeStep(int);
  50. float GetDeltaT();
  51. void TurnOn();
  52. void TurnOff();
  53. bool On();
  54. void SetSimTag(const char* tag);
  55. void SetDataDirectory(const char* dirname);
  56. virtual void SetName(const char*);
  57. virtual void Hallo();
  58. virtual int SaveSimInfo();
  59. virtual int WriteSimInfo(fstream &fw);
  60. virtual int WriteSimInfo(fstream &fw, const string &ChildInfo);
  61. virtual string GetSimInfo();
  62. virtual string GetSimInfo(const string &ChildInfo);
  63. virtual int StartRecorder(char* RecName="data.txt");
  64. virtual void SetParameter(ParaType p, double value);
  65. virtual bool compiledWithMemsave()
  66. {
  67. return compiledWithLowMemConfig();
  68. }
  69. SimLoop* getSimLoop() {return MainSimLoop;};
  70. };
  71. #endif // #ifndef SIMELEMENT__HPP