00001
00002
00003 #include <cassert>
00004 #include "Predictor.h"
00005
00006 using namespace Yosokumo;
00007
00008 Predictor::Predictor()
00009 {
00010 initPredictor(1, ACTIVE, CONTINUOUS, RATIO);
00011 }
00012
00013 Predictor::Predictor(int64_t name)
00014 {
00015 initPredictor(name, ACTIVE, CONTINUOUS, RATIO);
00016 }
00017
00018 Predictor::Predictor
00019 (
00020 int64_t name,
00021 Status status,
00022 Type type,
00023 Level level
00024 )
00025 {
00026 initPredictor(name, status, type, level);
00027 }
00028
00029 Predictor::Predictor(const Predictor &rhs)
00030 {
00031 initPredictor(rhs.name, rhs.status, rhs.type, rhs.level);
00032 }
00033
00034 Predictor::~Predictor()
00035 {}
00036
00037 Predictor &Predictor::operator=(const Predictor& rhs)
00038 {
00039 if (this != &rhs)
00040 initPredictor(rhs.name, rhs.status, rhs.type, rhs.level);
00041
00042 return *this;
00043 }
00044
00045 void Predictor::initPredictor
00046 (
00047 int64_t name,
00048 Status status,
00049 Type type,
00050 Level level
00051 )
00052 {
00053 setPredictorName(name );
00054 setStatus (status);
00055 setType (type );
00056 setLevel (level );
00057 }
00058
00059
00060
00061 bool Predictor::operator==(const Predictor &rhs) const
00062 {
00063 return
00064 (
00065 name == rhs.name &&
00066 status == rhs.status &&
00067 type == rhs.type &&
00068 level == rhs.level
00069 );
00070 }
00071
00072 bool Predictor::operator!=(const Predictor &rhs) const
00073 {
00074 return !(*this == rhs);
00075 }
00076
00077
00078
00079
00080 void Predictor::setPredictorName(int64_t name)
00081 {
00082 assert(name > 0);
00083 this->name = name;
00084 }
00085
00086 int64_t Predictor::getPredictorName() const
00087 {
00088 return name;
00089 }
00090
00091
00092 void Predictor::setStatus(Status s)
00093 {
00094 status = s;
00095 }
00096
00097 Predictor::Status Predictor::getStatus() const
00098 {
00099 return status;
00100 }
00101
00102
00103 void Predictor::setType(Type t)
00104 {
00105 type = t;
00106 }
00107
00108 Predictor::Type Predictor::getType() const
00109 {
00110 return type;
00111 }
00112
00113
00114 void Predictor::setLevel(Level L)
00115 {
00116 level = L;
00117 }
00118
00119 Predictor::Level Predictor::getLevel() const
00120 {
00121 return level;
00122 }
00123
00124
00125
00126
00127 std::string Predictor::toString()
00128 {
00129 std::stringstream s;
00130
00131 s <<
00132 "Predictor:" << '\n' <<
00133 " name = " << getPredictorName() << '\n' <<
00134 " status = " << getStatus() << '\n' <<
00135 " type = " << getType() << '\n' <<
00136 " level = " << getLevel() << '\n'
00137 ;
00138
00139 return s.str();
00140 }
00141
00142 std::ostream &Yosokumo::operator<<(std::ostream &os, Predictor &p)
00143 {
00144 os << p.toString();
00145 return os;
00146 }
00147
00148 std::stringstream &Yosokumo::operator<<(std::stringstream &s, Predictor &p)
00149 {
00150 s << p.toString();
00151 return s;
00152 }
00153
00154