00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _CJLINKSELECTOR_H_
00021 #define _CJLINKSELECTOR_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
00037 struct CjLinkSelector_ctor_va_t {
00039 bool m_add_remove;
00041 boost::mt19937 * m_rng;
00043 const CjNLTopology * m_top;
00045 std::string m_parent_name;
00046
00047 CjLinkSelector_ctor_va_t( CjNLTopology * top, boost::mt19937 * rng, bool isRemover ):m_add_remove(isRemover),m_rng(rng),m_top(top),m_parent_name("unknown object") {}
00048 CjLinkSelector_ctor_va_t( const CjNetworkProcess_ctor_va_t & temp, bool isRemover, std::string parent_name ):m_add_remove(isRemover),m_rng(temp.m_rng),m_top(temp.m_top),m_parent_name(parent_name) {}
00049 };
00050
00057 struct CjLinkSelector_select_va_t {
00059 int m_epoch;
00061 boost::mt19937 * const m_rng;
00062
00064 unsigned int m_node_a;
00066 unsigned int m_node_b;
00068
00072 bool m_selfloop_ok;
00074 bool m_bridge_ok;
00075
00076 CjLinkSelector_select_va_t( int epoch, boost::mt19937 * rng, bool selfloop_ok, bool bridge_ok ): \
00077 m_epoch(epoch),
00078 m_rng(rng),
00079 m_selfloop_ok(selfloop_ok),
00080 m_bridge_ok(bridge_ok)
00081 {}
00082
00083 CjLinkSelector_select_va_t( const CjNetworkProcess_act_va_t & temp, bool selfloop_ok, bool bridge_ok ): \
00084 m_epoch(temp.m_epoch),
00085 m_rng(temp.m_rng),
00086 m_selfloop_ok(selfloop_ok),
00087 m_bridge_ok(bridge_ok)
00088 {}
00089 };
00090
00095 struct wheelVal_t {
00096 union weight_t {
00097 double as_double;
00098 int as_int;
00099 unsigned int as_uint;
00100 } weight;
00101 unsigned int node_a;
00102 unsigned int node_b;
00103 bool valid;
00104 wheelVal_t( unsigned int node_a_, unsigned int node_b_ ):node_a(node_a_),node_b(node_b_),valid(true) { }
00105 wheelVal_t( double weight_, unsigned int node_a_, unsigned int node_b_ ):node_a(node_a_),node_b(node_b_),valid(true) { weight.as_double = weight_; }
00106 wheelVal_t( int weight_, unsigned int node_a_, unsigned int node_b_, int ):node_a(node_a_),node_b(node_b_),valid(true) { weight.as_int = weight_; }
00107 wheelVal_t( unsigned int weight_, unsigned int node_a_, unsigned int node_b_, int, int ):node_a(node_a_),node_b(node_b_),valid(true) { weight.as_uint = weight_; }
00108 };
00109
00118 class CjLinkSelector
00119 {
00120 public:
00121 typedef CjLinkSelector_ctor_va_t ctor_va_t;
00122 typedef CjLinkSelector_select_va_t select_arg_t;
00123
00125 static std::string getName_static() { throw std::logic_error("CjLinkSelector::getName_static() called."); }
00127 static std::string getProperty_static(const std::string &) { throw std::logic_error("CjLinkSelector::getProperty_static(..) called."); }
00129 virtual std::string getName() const = 0;
00131 virtual std::string getProperty(const std::string &) const = 0;
00132
00134 CjLinkSelector(const ctor_va_t & va):m_top(va.m_top),m_add_remove(va.m_add_remove),m_parent_name(va.m_parent_name) {}
00135
00137 virtual bool selectLink( select_arg_t &, unsigned int & from, unsigned int & to ) = 0;
00138 virtual ~CjLinkSelector() {};
00139
00140 protected:
00142 const CjNLTopology * m_top;
00144 bool m_add_remove;
00146 std::string m_parent_name;
00148
00155 static std::vector<wheelVal_t> m_wheel;
00156
00157 private:
00158
00159 };
00160
00161 }
00162
00163 #endif // _CJLINKSELECTOR_H_