CEBL  2.1
Plugin.hpp
Go to the documentation of this file.
1 /*
2 * CEBL : CSU EEG Brain-Computer Interface Lab
3 *
4 * Author: Jeshua Bratman - jeshuabratman@gmail.com
5 *
6 * This file is part of CEBL.
7 *
8 * CEBL is free software; you can redistribute it and/or modify it.
9 * We only ask that if you use our code that you cite the source in
10 * your project or publication.
11 *
12 * EEG Group (www.cs.colostate.edu/eeg)
13 * Department of Computer Science
14 * Colorado State University
15 *
16 */
17 
25 #ifndef CEBLPLUGIN_H
26 #define CEBLPLUGIN_H
27 
28 #include <string>
29 #include <map>
30 
31 #include "CEBLSerialization.hpp"
32 #include "../Exceptions.hpp"
33 #include "../Param.hpp"
34 
35 using std::string;
36 using std::map;
38 
39 namespace CEBL
40 {
41 
42  //----------------------------------------------------------------------
43 
44  class Plugin
45  {
46  protected:
47  string plugin_name;
49 
50  //function to inturrupt long calculation if ordered to halt
52  {
53  if(should_halt)
54  {
55  should_halt = false;
56  throw InturruptException(plugin_name + " was inturrupted.");
57  }
58  }
59 
60 
61  public:
62  Plugin() { plugin_name = "Unnamed Plugin"; should_halt = false;}
63  virtual ~Plugin() {}
64 
66  void halt() { should_halt = true; }
67 
69  string getName() const { return plugin_name; }
70 
71  //----------------------------------------------------------------------
72  //Function to override
73 
75  virtual std::map<std::string, CEBL::Param> getParamsList()
76  {
77  std::map<std::string, CEBL::Param> params;
78  return params;
79  }
81  virtual void setParamsList( std::map<std::string, CEBL::Param> &){}
82 
84  virtual map<string, SerializedObject> save() const
85  {
86  map<string, SerializedObject> ret;
87  return ret;
88  }
89 
91  virtual void load(map<string, SerializedObject> objects) {}
92 
93  };
94 }
95 #endif