7#include "ObservationNumberList.h"
10#include "IException.h"
12#include "SerialNumberList.h"
53 if (snlist->size() == 0) {
54 QString msg =
"Serial number list is empty";
58 map<QString, int> observationMap;
64 for (
int isn = 0; isn < snlist->size(); isn++) {
69 observationIndex = currentIndex++;
97 if (snlist->size() == 0) {
98 QString msg =
"Cannot remove, serial number list is empty";
105 map<QString, int> observationMap;
107 int currentIndex = 0;
108 int observationIndex;
111 for (
int isn = 0; isn < this->
size(); isn++) {
112 if ( (snlist->hasSerialNumber(this->serialNumber(isn))) ) {
120 observationIndex = currentIndex++;
155 QString observationNumber) {
158 nextset.serialNumberIndex = isn;
159 nextset.observationNumberIndex = observationIndex;
162 m_sets.push_back(nextset);
163 m_indexMap.insert(pair<int, int>(isn, observationIndex));
186 for (
unsigned index = 0; index <
m_pairs.size(); index++) {
228 QString msg =
"Requested filename [" +
FileName(filename).
expanded() +
"] ";
229 msg +=
"does not exist in the list";
233 return m_pairs[index].observationNumber;
247 if (index >= 0 && index < (
int)
m_pairs.size()) {
248 return m_pairs[index].observationNumber;
251 QString msg =
"Index [" +
toString(index) +
"] is invalid";
268 vector<QString> filenames;
269 for (
unsigned index = 0; index <
m_pairs.size(); index++) {
271 filenames.push_back(
m_pairs[index].filename);
274 if (filenames.size() > 0) {
278 QString msg =
"Requested observation number [" + on +
"] ";
279 msg +=
"does not exist in the list";
File name manipulation and expansion.
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
@ Programmer
This error is for when a programmer made an API call that was illegal.
std::vector< ObservationSet > m_sets
List of observation sets.
int observationSize() const
How many unique observations are in the list?
void init(SerialNumberList *snlist)
Initiates the ObservationNumberList.
bool hasObservationNumber(const QString &on)
Determines whether or not the requested observation number exists in the list.
~ObservationNumberList()
Destructor.
std::vector< QString > possibleFileNames(const QString &on)
Return possible filenames given an observation number.
ObservationNumberList(const QString &list, bool checkTarget=true)
Creates an ObservationNumberList from a filename.
void remove(SerialNumberList *snlist)
Removes all of the listed serial numbers from the observation.
QString observationNumber(const QString &filename)
Return an observation number given a filename.
void add(int isn, const int observationIndex, QString observationNumber)
Adds a new serial number index / observation number index / observation number to the SerialNumberLis...
int observationNumberMapIndex(const int serialNumberIndex)
Return a observation index given a serial number index.
int m_numberObservations
Count of observations in the observation number list.
std::multimap< int, int > m_indexMap
Maps serial number index to observation number index.
Serial Number list generator.
std::map< QString, int > m_fileMap
Maps filenames to their positions in the list.
int size() const
How many serial number / filename combos are in the list.
int serialNumberIndex(const QString &sn)
Return a list index given a serial number.
int fileNameIndex(const QString &filename)
Return a list index given a filename.
std::vector< Pair > m_pairs
List of serial number Pair entities.
This is free and unencumbered software released into the public domain.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Namespace for the standard library.
An observation consiting of a serial number index to the ObservationNumberList, an observation number...