Line data Source code
1 : /*******************************************************************************
2 : * *
3 : * Cosmos:(C)oncept et (O)utils (S)tatistique pour les (Mo)deles *
4 : * (S)tochastiques *
5 : * *
6 : * Copyright (C) 2009-2012 LSV & LACL *
7 : * Authors: Paolo Ballarini & Hilal Djafri *
8 : * Website: http://www.lsv.ens-cachan.fr/Software/cosmos *
9 : * *
10 : * This program is free software; you can redistribute it and/or modify *
11 : * it under the terms of the GNU General Public License as published by *
12 : * the Free Software Foundation; either version 3 of the License, or *
13 : * (at your option) any later version. *
14 : * *
15 : * This program is distributed in the hope that it will be useful, *
16 : * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 : * GNU General Public License for more details. *
19 : * *
20 : * You should have received a copy of the GNU General Public License along *
21 : * with this program; if not, write to the Free Software Foundation, Inc., *
22 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
23 : *******************************************************************************
24 : */
25 :
26 : #include "Event.hpp"
27 :
28 :
29 2477750 : Event::Event() : transition(0), time(-1.0), priority(0) , weight(0)
30 2477750 : {}
31 :
32 0 : Event::Event(unsigned int tr, double t): transition(tr),time(t), priority(0),weight(0),binding() {}
33 :
34 0 : Event::Event(unsigned int tr, double t, unsigned int pr, double w, const abstractBinding& b) :
35 0 : transition(tr),time(t), priority(pr),weight(w), binding(b) {}
36 :
37 :
38 :
39 1526 : Event::Event(const Event& orig) :
40 4578 : transition(orig.transition),time(orig.time), priority(orig.priority),
41 6104 : weight(orig.weight), binding(orig.binding) {}
42 :
43 2479276 : Event::~Event() {
44 2479276 : }
45 :
46 69516401 : const Event& Event::operator = (const Event& orig){
47 69516401 : transition = orig.transition;
48 69516401 : time = orig.time;
49 69516401 : priority = orig.priority;
50 69516401 : weight = orig.weight;
51 69516401 : binding = orig.binding;
52 69516401 : return *this;
53 : }
54 :
55 0 : void Event::setTime(double t) {
56 0 : time = t;
57 0 : }
58 :
59 0 : void Event::setPriority(size_t pr) {
60 0 : priority = pr;
61 :
62 0 : }
63 :
64 0 : void Event::setWeight(double w) {
65 0 : weight = w;
66 0 : }
67 :
68 144721118 : bool Event::isPriorer(const Event& e)const {
69 : //smallest time is priorer
70 144721118 : if (time > e.time) return false;
71 94913496 : if (time < e.time) return true;
72 : // if not(< or >) so it is =
73 : // highest priority is priorer
74 21768730 : if (priority < e.priority) return false;
75 21744567 : if (priority > e.priority) return true;
76 : //bigest weight is priorer
77 21737521 : if (weight > e.weight) return false;
78 14957158 : else return true;
79 : }
80 :
81 0 : std::ostream& operator<<(std::ostream& os, const Event& e)
82 : {
83 0 : os << e.transition << ":" << e.binding.id() << ":" << e.time ;
84 0 : return os;
85 87 : }
86 :
|