Swarm-NG  1.1
monitor_template.hpp
Go to the documentation of this file.
1 /*************************************************************************
2  * Copyright (C) 2011 by Saleh Dindar and the Swarm-NG Development Team *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 3 of the License. *
7  * *
8  * This program is distributed in the hope that it will be useful, *
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
11  * GNU General Public License for more details. *
12  * *
13  * You should have received a copy of the GNU General Public License *
14  * along with this program; if not, write to the *
15  * Free Software Foundation, Inc., *
16  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
17  ************************************************************************/
18 
24 #pragma once
25 
26 #include <limits>
27 
28 namespace swarm {
29 
33  namespace monitors {
38  };
39 
45 template<class log_t>
47  public:
49 
50  private:
51  params _params;
52  ensemble::SystemRef& _sys;
53  log_t& _log;
54 
55  public:
56 
58  GPUAPI bool is_deactivate_on() { return false; }
59  GPUAPI bool is_log_on() { return false; }
60  GPUAPI bool is_verbose_on() { return false; }
61  GPUAPI bool is_any_on() { return is_deactivate_on() || is_log_on() || is_verbose_on() ; }
62  GPUAPI bool is_condition_met () { return false; }
63  GPUAPI bool need_to_log_system ()
64  { return (is_log_on() && is_condition_met() ); }
65  GPUAPI bool need_to_deactivate ()
66  { return ( is_deactivate_on() && is_condition_met() ); }
67 
68 
70  GPUAPI bool pass_one (int thread_in_system)
71  { return false; }
72 
74  GPUAPI int pass_two (int thread_in_system)
75  {
76  if(is_condition_met() && is_deactivate_on() && (thread_in_system==0) )
77  { _sys.set_disabled(); }
78  return _sys.state();
79  }
80 
81  GPUAPI void operator () (const int thread_in_system)
82  {
83  pass_one(thread_in_system);
84  pass_two(thread_in_system);
85  if(need_to_log_system() && (thread_in_system()==0) )
86  log::system(_log, _sys);
87  }
88 
89 #if 0
90  // GPUAPI void operator () () {
91  GPUAPI void operator () (const int thread_in_system) {
92  // _sys.set_inactive();
93  //_sys.set_disabled();
94  // log::system(_log,_sys);
95  }
96 #endif
97 
99  GPUAPI monitor_template(const params& p,ensemble::SystemRef& s,log_t& l)
100  :_params(p),_sys(s),_log(l){}
101 
102 };
103 
104 }
105 
106 }