Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 14bb6f71 authored by David Parsons's avatar David Parsons
Browse files

Add an ObservableEvent to the observation "update" method

parent e40bb3bd
Branches
Tags
No related merge requests found
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
// ============================================================================ // ============================================================================
void Observable::notifyObservers(ObservableEvent e, void* arg) { void Observable::notifyObservers(ObservableEvent e, void* arg) {
for (auto& o : observers_[e]) { for (auto& o : observers_[e]) {
o->update(*this, arg); o->update(*this, e, arg);
} }
} }
......
...@@ -58,7 +58,7 @@ class Observer { ...@@ -58,7 +58,7 @@ class Observer {
// Public Methods // Public Methods
// ========================================================================== // ==========================================================================
/// This method is called whenever the observed object is changed. /// This method is called whenever the observed object is changed.
virtual void update(Observable& o, void* arg) = 0; virtual void update(Observable& o, ObservableEvent e, void* arg) = 0;
// ========================================================================== // ==========================================================================
// Getters // Getters
......
...@@ -257,7 +257,8 @@ void ReplicationReport::write_to_tree_file(gzFile tree_file) const ...@@ -257,7 +257,8 @@ void ReplicationReport::write_to_tree_file(gzFile tree_file) const
// ================================================================= // =================================================================
// Non inline accessors // Non inline accessors
// ================================================================= // =================================================================
void ReplicationReport::update(Observable& o, void* arg) { void ReplicationReport::update(Observable& o, ObservableEvent e, void* arg) {
assert(e == END_REPLICATION);
signal_end_of_replication(dynamic_cast<Individual*>(&o)); signal_end_of_replication(dynamic_cast<Individual*>(&o));
} }
} // namespace aevol } // namespace aevol
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "DnaReplicationReport.h" #include "DnaReplicationReport.h"
#include "ae_enums.h" #include "ae_enums.h"
#include "Observer.h" #include "Observer.h"
#include "ObservableEvent.h"
#include "Individual.h" #include "Individual.h"
namespace aevol { namespace aevol {
...@@ -124,7 +125,7 @@ class ReplicationReport : public Observer ...@@ -124,7 +125,7 @@ class ReplicationReport : public Observer
void write_to_tree_file(gzFile tree_file) const; void write_to_tree_file(gzFile tree_file) const;
void update(Observable& o, void* arg) override; void update(Observable& o, ObservableEvent e, void* arg) override;
......
...@@ -277,7 +277,7 @@ void Tree::write_to_tree_file(gzFile tree_file) ...@@ -277,7 +277,7 @@ void Tree::write_to_tree_file(gzFile tree_file)
} }
} }
void Tree::update(Observable& o, void* arg) { void Tree::update(Observable& o, ObservableEvent e, void* arg) {
auto indivs = reinterpret_cast<Individual**>(arg); auto indivs = reinterpret_cast<Individual**>(arg);
get_report_by_index(Time::get_time(), indivs[0]->get_id())->init(indivs[0], get_report_by_index(Time::get_time(), indivs[0]->get_id())->init(indivs[0],
indivs[1]); indivs[1]);
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "ReplicationReport.h" #include "ReplicationReport.h"
#include "Observer.h" #include "Observer.h"
#include "ObservableEvent.h"
#include "ae_enums.h" #include "ae_enums.h"
...@@ -103,7 +104,7 @@ class Tree : public Observer ...@@ -103,7 +104,7 @@ class Tree : public Observer
*/ */
inline int64_t get_LCA(int64_t t, int32_t a, int32_t b, int32_t *j); inline int64_t get_LCA(int64_t t, int32_t a, int32_t b, int32_t *j);
void update(Observable& o, void* arg) override; void update(Observable& o, ObservableEvent e, void* arg) override;
// ================================================================= // =================================================================
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment