]> git.donarmstrong.com Git - mothur.git/blob - collectorscurvedata.h
changes while testing
[mothur.git] / collectorscurvedata.h
1 #ifndef COLLECTORSCURVEDATA_H
2 #define COLLECTORSCURVEDATA_H
3
4 #include "sabundvector.hpp"
5 #include "sharedrabundvector.h"
6 #include "display.h"
7 #include "observable.h"
8
9
10 /***********************************************************************/
11
12 class CollectorsCurveData : public Observable {
13         
14 public:
15         CollectorsCurveData() : rank(0) {};
16         
17         void registerDisplay(Display* o)                {       displays.insert(o);                             };
18         void removeDisplay(Display* o)                  {       displays.erase(o);      delete o;       };
19         SAbundVector* getRankData()                             {       return rank;                                    };
20         void rankDataChanged()                                  {       notifyDisplays();                               };
21         void updateRankData(SAbundVector* rv)   {       rank = rv; rankDataChanged();   };
22
23         void notifyDisplays(){  
24                 for(set<Display*>::iterator pos=displays.begin();pos!=displays.end();pos++){
25                         (*pos)->update(rank);
26                 }       
27         };
28         
29 private:
30         set<Display*> displays;
31         SAbundVector* rank;
32         
33 };
34
35 /***********************************************************************/
36
37
38 class SharedCollectorsCurveData : public Observable {
39         
40 public:
41         SharedCollectorsCurveData() { }; //: shared1(0), shared2(0)
42         
43         void registerDisplay(Display* o)                {       displays.insert(o);                     };
44         void removeDisplay(Display* o)                  {       displays.erase(o);      delete o;       };
45         void SharedDataChanged()                                {       notifyDisplays();                               };
46         void updateSharedData(vector<SharedRAbundVector*> s, int numSeqs, int numGroupComb, bool p)     {       pairs = p; shared = s; NumSeqs = numSeqs; NumGroupComb = numGroupComb; SharedDataChanged();     };
47         
48         void notifyDisplays(){  
49                 for(set<Display*>::iterator pos=displays.begin();pos!=displays.end();pos++){
50                         
51                         if ((*pos)->calcNeedsAll() == true) {
52                                 (*pos)->update(shared, NumSeqs, NumGroupComb);
53                         }else{
54                                 
55                                 if ( ((*pos)->isCalcMultiple() == true) && ((*pos)->getAll() == true) && (!pairs) ) {
56                                         (*pos)->update(shared, NumSeqs, NumGroupComb);
57                                 }else {
58                                         vector<SharedRAbundVector*> temp; temp.push_back(shared[0]); temp.push_back(shared[1]);
59                                         shared = temp; 
60                                         
61                                         (*pos)->update(shared, NumSeqs, NumGroupComb);
62                                 }
63                         }
64                 }       
65         };
66         
67 private:
68         set<Display*> displays;
69         vector<Display*> multiDisplays;
70         vector<SharedRAbundVector*> shared;
71         int NumSeqs, NumGroupComb;
72         bool pairs;
73 };
74
75 /***********************************************************************/
76
77 #endif
78