summaryrefslogtreecommitdiff
path: root/cad/plugins/NanoVision-1/src/Interface/NXDataStoreInfo.cpp
blob: 22ea92c705f2527d9e211f2122562fcbb5e300e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251

// Copyright 2008 Nanorex, Inc.  See LICENSE file for details. 

#include "Nanorex/Interface/NXDataStoreInfo.h"

namespace Nanorex {


/* CONSTRUCTOR */
NXDataStoreInfo::NXDataStoreInfo() 
    : _isSimulationResults(false),
    _isSingleStructure(false),
    _inputParameters(NULL),
    _resultsSummary(NULL),
	_clipboardStructure(NULL)
{
}


NXDataStoreInfo::~NXDataStoreInfo()
{
	reset(); // will also release owned resources, like clipboard data
}


/* FUNCTION: reset */
void NXDataStoreInfo::reset(void)
{
    _fileNames.clear();
    _inputStructures.clear();
    _trajectories.clear();
    _handle.clear();
    _isLastFrame.clear();
    _storeIsComplete.clear();
    _isSimulationResults = false;
    _isSingleStructure = false;
    if(_inputParameters != NULL) delete _inputParameters;
    if(_resultsSummary != NULL) delete _resultsSummary;
    _inputParameters = _resultsSummary = NULL;
	if(_clipboardStructure != NULL) delete _clipboardStructure;
	_clipboardStructure = NULL;
	homeView.setName("");
	lastView.setName("");
	otherViews.clear();
}


/* FUNCTION: isSingleStructure */
/*
 * @return	True if this data store has only a single frame of structure
 *			data such as in an MMP or PDB file.
 */
bool NXDataStoreInfo::isSingleStructure() { return _isSingleStructure; }


/* FUNCTION: setIsSingleStructure */
void NXDataStoreInfo::setIsSingleStructure(bool _isSingleStructure) {
	this->_isSimulationResults = !_isSingleStructure;
	this->_isSingleStructure = _isSingleStructure;
}


/* FUNCTION: getSingleStructureFileName */
const string& NXDataStoreInfo::getSingleStructureFileName() {
	return (*(_fileNames.begin())).second;
}

		
/* FUNCTION: getSingleStructureId */
int NXDataStoreInfo::getSingleStructureId() {
	return (*(_fileNames.begin())).first;
}


/* FUNCTION: isSimulationResults */
/*
 * @return	True if this data store encapsulates simulation results.
 */
bool NXDataStoreInfo::isSimulationResults() { return _isSimulationResults; }


/* FUNCTION: setIsSimulationResults */
void NXDataStoreInfo::setIsSimulationResults(bool _isSimulationResults) {
	this->_isSimulationResults = _isSimulationResults;
	this->_isSingleStructure = !_isSimulationResults;
}


/* FUNCTION: getInputParameters */
/*
 * @return	Null if this data store doens't have any input parameters.
 */
NXProperties* NXDataStoreInfo::getInputParameters() {
	return _inputParameters;
}


/* FUNCTION: setInputParameters */
void NXDataStoreInfo::setInputParameters(NXProperties* parameters) {
	_inputParameters = parameters;
}


/* FUNCTION: getInputFileNames */
/*
 * @return	A vector of input file names. The vector will be empty if
 *			there are no input file names in this data store.
 */
vector<string> NXDataStoreInfo::getInputFileNames() {
	map<string, int>::iterator iter = _inputStructures.begin();
	vector<string> names;
	while (iter != _inputStructures.end()) {
		names.push_back((*iter).first);
		iter++;
	}
	return names;
}


/* FUNCTION: addInputStructure */
void NXDataStoreInfo::addInputStructure(const string& fileName) {
	_inputStructures[fileName] = -1;
}


/* FUNCTION: getInputStructureId */
/*
 * @return The frame set identifier for the given input structure file name.
 */
int NXDataStoreInfo::getInputStructureId(const string& fileName) {
	return _inputStructures[fileName];
}


/* FUNCTION: setInputStructureId */
void NXDataStoreInfo::setInputStructureId(const string& fileName,
										  int frameSetId) {
	_inputStructures[fileName] = frameSetId;
}


/* FUNCTION: getResultsSummary */
/*
 * @return	Null if this data store doesn't have any results summary data.
 */
NXProperties* NXDataStoreInfo::getResultsSummary() {
	return _resultsSummary;
}


/* FUNCTION: setResultsSummary */
void NXDataStoreInfo::setResultsSummary(NXProperties* resultsSummary) {
	if (_resultsSummary != NULL)
		delete _resultsSummary;
	_resultsSummary = resultsSummary;
}


/* FUNCTION: getTrajectoryNames */
/*
 * @return	A vector of trajectory names. The vector will be empty if
 *			there are no trajectories in this data store.
 */
vector<string> NXDataStoreInfo::getTrajectoryNames() {
	map<string, int>::iterator iter = _trajectories.begin();
	vector<string> names;
	while (iter != _trajectories.end()) {
		names.push_back((*iter).first);
		iter++;
	}
	return names;
}


/* FUNCTION: addTrajectory */
void NXDataStoreInfo::addTrajectory(const string& name, int frameSetId) {
	_trajectories[name] = frameSetId;
}


/* FUNCTION: getTrajectoryId */
int NXDataStoreInfo::getTrajectoryId(const string& name) {
	return _trajectories[name];
}


/* FUNCTION: setLastFrame */
/*
 * Last frame flags (whether the last frame-index is the last
 * frame available in the data store, ie, stop trying to read frames
 * (for now.))
 */
void NXDataStoreInfo::setLastFrame(int frameSetId, bool isLastFrame) {
	_isLastFrame[frameSetId] = isLastFrame;
}


/* FUNCTION: isLastFrame */
bool NXDataStoreInfo::isLastFrame(int frameSetId) {
	return _isLastFrame[frameSetId];
}


/* FUNCTION: storeIsComplete */
/*
 * @return	True if the frame set specified by the frameSetId is
 *			complete, and false if something is still writing frames
 *			to the specified frame set.
 */
bool NXDataStoreInfo::storeIsComplete(int frameSetId) {
	return _storeIsComplete[frameSetId];
}


/* FUNCTION: setStoreComplete */
/*
 * Store complete flags (whether the data store's frame set is complete
 * (true) or if something is still writing new frames to it (false.))
 */
void NXDataStoreInfo::setStoreComplete(int frameSetId, bool storeIsComplete) {
	_storeIsComplete[frameSetId] = storeIsComplete;
}

// TODO: check for existence in getters

/* FUNCTION: getFileName */
const string& NXDataStoreInfo::getFileName(int frameSetId) {
	return _fileNames[frameSetId];
}


/* FUNCTION: setFileName */
void NXDataStoreInfo::setFileName(const string& filename, int frameSetId) {
	_fileNames[frameSetId] = filename;
}


/* FUNCTION: setHandle */
/*
 * (Data store/file) handles
 */
void NXDataStoreInfo::setHandle(int frameSetId, void* handle) {
	_handle[frameSetId] = handle;
}


/* FUNCTION: getHandle */
void* NXDataStoreInfo::getHandle(int frameSetId) { return _handle[frameSetId]; }


} // Nanorex::