00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _CJNODESELECTOR_H_
00021 #define _CJNODESELECTOR_H_ 1
00022
00023 #include <string>
00024 #include "CjNLTopology.hh"
00025 #include "CjMatrix.hh"
00026 #include <boost/random/mersenne_twister.hpp>
00027 #include "CjNetworkProcess.hh"
00028
00029 namespace jmitie {
00030
00031 class CjNodeSelector;
00032
00034
00036 struct CjNodeSelector_ctor_va_t {
00038 bool m_src_dest;
00040 bool m_add_remove;
00042 boost::mt19937 * m_rng;
00044 const CjNLTopology * m_top;
00046 std::string m_parent_name;
00047
00048 CjNodeSelector_ctor_va_t( CjNLTopology * top, boost::mt19937 * rng, bool isDest, bool isRemove, std::string parent_name ):m_src_dest(isDest),m_add_remove(isRemove),m_rng(rng),m_top(top),m_parent_name(parent_name) {}
00049 CjNodeSelector_ctor_va_t( const CjNetworkProcess_ctor_va_t & temp, bool isDest, bool isRemove, std::string parent_name ):m_src_dest(isDest),m_add_remove(isRemove),m_rng(temp.m_rng),m_top(temp.m_top),m_parent_name(parent_name) {}
00050 };
00051
00053
00055 struct CjNodeSelector_select_va_t {
00057 int m_epoch;
00059 boost::mt19937 * m_rng;
00060
00062
00066 std::vector<int> * m_invalid_choice;
00067
00069 int m_start_node;
00071 bool m_skip_start;
00073
00076 bool m_skip_fullconn;
00078 bool m_selfloop_ok;
00079
00080 CjNodeSelector_select_va_t( int epoch, boost::mt19937 * rng, int start_node = -1, bool skip_start = true, bool skip_fullconn = true, bool selfloop_ok = false ): \
00081 m_epoch(epoch),
00082 m_rng(rng),
00083 m_invalid_choice(0),
00084 m_start_node(start_node),
00085 m_skip_start(skip_start),
00086 m_skip_fullconn(skip_fullconn),
00087 m_selfloop_ok(selfloop_ok)
00088 {}
00089 CjNodeSelector_select_va_t( const CjNetworkProcess_act_va_t & temp, int start_node = -1, bool skip_start = true, bool skip_fullconn = true, bool selfloop_ok = false ): \
00090 m_epoch(temp.m_epoch),
00091 m_rng(temp.m_rng),
00092 m_invalid_choice(0),
00093 m_start_node(start_node),
00094 m_skip_start(skip_start),
00095 m_skip_fullconn(skip_fullconn),
00096 m_selfloop_ok(selfloop_ok)
00097 {}
00098
00099 CjNodeSelector_select_va_t( int epoch, std::vector<int> * invalid_choice, boost::mt19937 * rng, int start_node = -1, bool skip_start = true, bool skip_fullconn = true, bool selfloop_ok = false ): \
00100 m_epoch(epoch),
00101 m_rng(rng),
00102 m_invalid_choice(invalid_choice),
00103 m_start_node(start_node),
00104 m_skip_start(skip_start),
00105 m_skip_fullconn(skip_fullconn),
00106 m_selfloop_ok(selfloop_ok)
00107 {}
00108 CjNodeSelector_select_va_t( std::vector<int> * invalid_choice, const CjNetworkProcess_act_va_t & temp, int start_node = -1, bool skip_start = true, bool skip_fullconn = true, bool selfloop_ok = false ): \
00109 m_epoch(temp.m_epoch),
00110 m_rng(temp.m_rng),
00111 m_invalid_choice(invalid_choice),
00112 m_start_node(start_node),
00113 m_skip_start(skip_start),
00114 m_skip_fullconn(skip_fullconn),
00115 m_selfloop_ok(selfloop_ok)
00116 {}
00117 };
00118
00127 class CjNodeSelector
00128 {
00129 public:
00131 typedef CjNodeSelector_ctor_va_t ctor_va_t;
00133 typedef CjNodeSelector_select_va_t select_arg_t;
00134
00136 CjNodeSelector(const ctor_va_t & va):m_top(va.m_top),m_parent_name(va.m_parent_name),m_src_dest(va.m_src_dest),m_add_remove(va.m_add_remove) { }
00137
00139 static std::string getName_static() { throw std::logic_error("CjNodeSelector::getName_static() called."); }
00141 static std::string getProperty_static(const std::string &) { throw std::logic_error("CjNodeSelector::getProperty_static(..) called."); }
00143 virtual std::string getName() const = 0;
00145 virtual std::string getProperty(const std::string &) const = 0;
00146
00148
00150 virtual bool selectNode( select_arg_t &, unsigned int & node ) = 0;
00151 virtual ~CjNodeSelector() {};
00152
00153 protected:
00155 const CjNLTopology * m_top;
00157 std::string m_parent_name;
00159 bool m_src_dest;
00161 bool m_add_remove;
00162
00163
00164 private:
00165
00166 };
00167
00168 }
00169
00170 #endif // _CJNODESELECTOR_H_