1 // $Id: gc_panel.cpp,v 1.1 2011/06/22 18:22:22 jmcgill Exp $
2
3 /*
4 Copyright 2002 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 #include <cassert>
12
13 #include "gc_creation_info.h" // JRM this doing anything?
14 #include "gc_errhandling.h"
15 #include "gc_data.h" // for ToWxString
16 #include "gc_default.h"
17 #include "gc_panel.h"
18 //#include "gc_panel_err.h"
19 #include "gc_strings.h"
20 //#include "gc_strings_panel.h"
21 #include "gc_structures_err.h"
22 #include "wx/log.h"
23 #include "wx/string.h"
24 #include "wx/tokenzr.h"
25
26 //------------------------------------------------------------------------------------
27
gcPanel()28 gcPanel::gcPanel()
29 :
30 m_blessed(false),
31 m_hasRegion(false),
32 m_regionId(gcdefault::badIndex),
33 m_hasPop(false),
34 m_popId(gcdefault::badIndex),
35 m_nPanels(0)
36 {
37 }
38
~gcPanel()39 gcPanel::~gcPanel()
40 {
41 }
42
43 void
SetBlessed(bool blessed)44 gcPanel::SetBlessed(bool blessed)
45 {
46 m_blessed = blessed;
47 }
48
49 bool
GetBlessed() const50 gcPanel::GetBlessed() const
51 {
52 return m_blessed;
53 }
54
55 void
DebugDump(wxString prefix) const56 gcPanel::DebugDump(wxString prefix) const
57 {/*
58 wxLogDebug("%spanel %s (panel id %ld)", // JMDUMPOK
59 prefix.c_str(),
60 GetName().c_str(),
61 (long)GetId());
62 wxLogDebug("%sregion %s",(prefix+gcstr::indent).c_str(),ToWxString(GetRegionID()).c_str()); // JMDUMPOK
63 wxLogDebug("%s%s population",(prefix+gcstr::indent).c_str(),GetPopulation().c_str()); // JMDUMPOK
64 wxLogDebug("%s%s number of panels",(prefix+gcstr::indent).c_str(),GetNumPanels.c_str()); // JMDUMPOK
65 */
66 wxLogVerbose("%spanel %s (panel id %ld)", // JMDUMPOK
67 prefix.c_str(),
68 GetName().c_str(),
69 (long)GetId());
70 wxLogVerbose("%sregion %s",(prefix+gcstr::indent).c_str(),GetRegionIdString().c_str()); // JMDUMPOK
71 wxLogVerbose("%s%s population",(prefix+gcstr::indent).c_str(),GetPopIdString().c_str()); // JMDUMPOK
72 wxLogVerbose("%s%s number of panels",(prefix+gcstr::indent).c_str(),GetNumPanelsString().c_str()); // JMDUMPOK
73 }
74
75 void
SetRegionId(size_t id)76 gcPanel::SetRegionId(size_t id)
77 {
78 m_regionId = id;
79 m_hasRegion = true;
80 }
81
82 void
UnsetRegionId()83 gcPanel::UnsetRegionId()
84 {
85 m_regionId = gcdefault::badIndex;
86 m_hasRegion = false;
87 }
88
89 bool
HasRegion() const90 gcPanel::HasRegion() const
91 {
92 return m_hasRegion;
93 }
94
95 size_t
GetRegionId() const96 gcPanel::GetRegionId() const
97 {
98 if(!HasRegion())
99 {
100 wxString msg = wxString::Format(gcerr::unsetRegionId,GetName().c_str());
101 throw gc_implementation_error(msg.c_str());
102 }
103 return m_regionId;
104 }
105
106 wxString
GetRegionIdString() const107 gcPanel::GetRegionIdString() const
108 {
109 if(HasRegion())
110 {
111 return wxString::Format("%d",(int)GetRegionId());
112 }
113 return gcstr::unknown;
114 }
115
116 void
SetPopId(size_t id)117 gcPanel::SetPopId(size_t id)
118 {
119 m_popId = id;
120 m_hasPop = true;
121 }
122
123 void
UnsetPopId()124 gcPanel::UnsetPopId()
125 {
126 m_popId = gcdefault::badIndex;
127 m_hasPop = false;
128 }
129
130 bool
HasPop() const131 gcPanel::HasPop() const
132 {
133 return m_hasPop;
134 }
135
136 size_t
GetPopId() const137 gcPanel::GetPopId() const
138 {
139 if(!HasPop())
140 {
141 wxString msg = wxString::Format(gcerr::unsetPopId,GetName().c_str());
142 throw gc_implementation_error(msg.c_str());
143 }
144 return m_popId;
145 }
146
147 wxString
GetPopIdString() const148 gcPanel::GetPopIdString() const
149 {
150 if(HasPop())
151 {
152 return wxString::Format("%d",(int)GetPopId());
153 }
154 return gcstr::unknown;
155 }
156
157 void
SetNumPanels(long val)158 gcPanel::SetNumPanels(long val)
159 {
160 m_nPanels = val;
161 }
162
163 long
GetNumPanels() const164 gcPanel::GetNumPanels() const
165 {
166 return m_nPanels;
167 }
168
169 wxString
GetNumPanelsString() const170 gcPanel::GetNumPanelsString() const
171 {
172 return wxString::Format("%d",(int)GetNumPanels());
173 }
174 //____________________________________________________________________________________
175