1 // $Id: data_interface.cpp,v 1.32 2012/02/15 18:13:42 jmcgill Exp $
2 
3 /*
4  *  Copyright 2002  Peter Beerli, Mary Kuhner, Jon Yamato and Joseph Felsenstein
5  *
6  *  This software is distributed free of charge for non-commercial use
7  *  and is copyrighted.  Of course, we do not guarantee that the software
8  *  works, and are not responsible for any damage you may cause or have.
9  *
10  */
11 
12 #include "data_interface.h"
13 #include "setget.h"
14 #include "ui_vars.h"
15 #include "ui_strings.h"
16 #include "vectorx.h"
17 
18 #include <iostream>
19 
20 //------------------------------------------------------------------------------------
21 
Get(UIVars & vars,UIId id)22 long uiCrossPartitionCount::Get(UIVars& vars, UIId id)
23 {
24     return vars.datapackplus.GetNCrossPartitions();
25 }
26 
uiCrossPartitionCount()27 uiCrossPartitionCount::uiCrossPartitionCount()
28     : GetLong(uistr::crossPartitionCount)
29 {
30 }
31 
~uiCrossPartitionCount()32 uiCrossPartitionCount::~uiCrossPartitionCount()
33 {
34 }
35 
36 //------------------------------------------------------------------------------------
37 
Get(UIVars & vars,UIId id)38 long uiDivMigPartitionCount::Get(UIVars& vars, UIId id)
39 {
40     return vars.datapackplus.GetNPartitionsByForceType(force_DIVMIG);
41 }
42 
uiDivMigPartitionCount()43 uiDivMigPartitionCount::uiDivMigPartitionCount()
44     : GetLong(uistr::divmigrationPartitionCount)
45 {
46 }
47 
~uiDivMigPartitionCount()48 uiDivMigPartitionCount::~uiDivMigPartitionCount()
49 {
50 }
51 
52 //------------------------------------------------------------------------------------
53 
Get(UIVars & vars,UIId id)54 string uiDivMigPartitionName::Get(UIVars& vars, UIId id)
55 {
56     return vars.datapackplus.GetForcePartitionName(force_DIVMIG,id.GetIndex1());
57 }
58 
uiDivMigPartitionName()59 uiDivMigPartitionName::uiDivMigPartitionName()
60     : GetString(uistr::divmigrationPartitionName)
61 {
62 }
63 
~uiDivMigPartitionName()64 uiDivMigPartitionName::~uiDivMigPartitionName()
65 {
66 }
67 
68 //------------------------------------------------------------------------------------
69 
Get(UIVars & vars,UIId id)70 long uiMigPartitionCount::Get(UIVars& vars, UIId id)
71 {
72     return vars.datapackplus.GetNPartitionsByForceType(force_MIG);
73 }
74 
uiMigPartitionCount()75 uiMigPartitionCount::uiMigPartitionCount()
76     : GetLong(uistr::migrationPartitionCount)
77 {
78 }
79 
~uiMigPartitionCount()80 uiMigPartitionCount::~uiMigPartitionCount()
81 {
82 }
83 
84 //------------------------------------------------------------------------------------
85 
Get(UIVars & vars,UIId id)86 string uiMigPartitionName::Get(UIVars& vars, UIId id)
87 {
88     return vars.datapackplus.GetForcePartitionName(force_MIG,id.GetIndex1());
89 }
90 
uiMigPartitionName()91 uiMigPartitionName::uiMigPartitionName()
92     : GetString(uistr::migrationPartitionName)
93 {
94 }
95 
~uiMigPartitionName()96 uiMigPartitionName::~uiMigPartitionName()
97 {
98 }
99 
100 //------------------------------------------------------------------------------------
101 
Get(UIVars & vars,UIId id)102 long uiDiseasePartitionCount::Get(UIVars& vars, UIId id)
103 {
104     return vars.datapackplus.GetNPartitionsByForceType(force_DISEASE);
105 }
106 
uiDiseasePartitionCount()107 uiDiseasePartitionCount::uiDiseasePartitionCount()
108     : GetLong(uistr::diseasePartitionCount)
109 {
110 }
111 
~uiDiseasePartitionCount()112 uiDiseasePartitionCount::~uiDiseasePartitionCount()
113 {
114 }
115 
116 //------------------------------------------------------------------------------------
117 
Get(UIVars & vars,UIId id)118 string uiDiseasePartitionName::Get(UIVars& vars, UIId id)
119 {
120     return vars.datapackplus.GetForcePartitionName(force_DISEASE,id.GetIndex1());
121 }
122 
uiDiseasePartitionName()123 uiDiseasePartitionName::uiDiseasePartitionName()
124     : GetString(uistr::diseasePartitionName)
125 {
126 }
127 
~uiDiseasePartitionName()128 uiDiseasePartitionName::~uiDiseasePartitionName()
129 {
130 }
131 
132 //------------------------------------------------------------------------------------
133 
Get(UIVars & vars,UIId id)134 LongVec1d uiLociNumbers::Get(UIVars& vars, UIId id)
135 {
136     long count = vars.datapackplus.GetNumLoci(id.GetIndex1());
137     LongVec1d longVec;
138     for(long i= 0; i< count; i++)
139     {
140         longVec.push_back(i);
141     }
142     return longVec;
143 }
144 
uiLociNumbers()145 uiLociNumbers::uiLociNumbers()
146     : GetLongVec1d(uistr::lociNumbers)
147 {
148 }
149 
~uiLociNumbers()150 uiLociNumbers::~uiLociNumbers()
151 {
152 }
153 
154 //------------------------------------------------------------------------------------
155 
Get(UIVars & vars,UIId id)156 LongVec1d uiRegionNumbers::Get(UIVars& vars, UIId id)
157 {
158     long count = vars.datapackplus.GetNumRegions();
159     LongVec1d longVec;
160     for(long i= 0; i< count; i++)
161     {
162         longVec.push_back(i);
163     }
164     return longVec;
165 }
166 
uiRegionNumbers()167 uiRegionNumbers::uiRegionNumbers()
168     : GetLongVec1d(uistr::regionNumbers)
169 {
170 }
171 
~uiRegionNumbers()172 uiRegionNumbers::~uiRegionNumbers()
173 {
174 }
175 
176 //------------------------------------------------------------------------------------
177 
uiRegionEffectivePopSize()178 uiRegionEffectivePopSize::uiRegionEffectivePopSize()
179     : SetGetDouble(uistr::effectivePopSize)
180 {
181 }
182 
~uiRegionEffectivePopSize()183 uiRegionEffectivePopSize::~uiRegionEffectivePopSize()
184 {
185 }
186 
Get(UIVars & vars,UIId id)187 double uiRegionEffectivePopSize::Get(UIVars& vars, UIId id)
188 {
189     return vars.datapackplus.GetEffectivePopSize(id.GetIndex1());
190 }
191 
Set(UIVars & vars,UIId id,double size)192 void uiRegionEffectivePopSize::Set(UIVars& vars, UIId id, double size)
193 {
194     vars.datapackplus.SetEffectivePopSize(id.GetIndex1(), size);
195 }
196 
197 //------------------------------------------------------------------------------------
198 
uiSimulateData()199 uiSimulateData::uiSimulateData()
200     : SetGetBool(uistr::simulateData)
201 {
202 }
203 
~uiSimulateData()204 uiSimulateData::~uiSimulateData()
205 {
206 }
207 
Get(UIVars & vars,UIId id)208 bool uiSimulateData::Get(UIVars& vars, UIId id)
209 {
210     return vars.datapackplus.GetSimulateData(id.GetIndex1(), id.GetIndex2());
211 }
212 
Set(UIVars & vars,UIId id,bool sim)213 void uiSimulateData::Set(UIVars& vars, UIId id, bool sim)
214 {
215     vars.datapackplus.SetSimulateData(id.GetIndex1(), id.GetIndex2(), sim);
216 }
217 
218 //____________________________________________________________________________________
219