Commit 6b6cb6eb authored by Russell Taylor's avatar Russell Taylor
Browse files

Clear a couple of MSVC warnings. Re #4473.

Also move some definitions from the PeaksWorkspace header to the cpp.
parent 0fce0283
......@@ -70,7 +70,7 @@ namespace API
/** Removes the indicated peak
* @param peakNum the peak to remove. peakNum starts at 0
*/
virtual void removePeak(const int peakNum) = 0;
virtual void removePeak(int peakNum) = 0;
//---------------------------------------------------------------------------------------------
/** Add a peak to the list
......@@ -83,7 +83,7 @@ namespace API
* @param peakNum :: index of the peak to get.
* @return a reference to a Peak object.
*/
virtual IPeak & getPeak(const int peakNum) = 0;
virtual IPeak & getPeak(int peakNum) = 0;
//---------------------------------------------------------------------------------------------
/** Return a pointer to the Peak
......
......@@ -87,77 +87,14 @@ namespace DataObjects
void sort(std::vector< std::pair<std::string, bool> > & criteria);
//---------------------------------------------------------------------------------------------
/** @return the number of peaks
*/
int getNumberPeaks() const
{
return int(peaks.size());
}
//---------------------------------------------------------------------------------------------
/** Removes the indicated peak
* @param peakNum the peak to remove. peakNum starts at 0
*/
void removePeak(const int peakNum)
{
if (peakNum >= static_cast<int>(peaks.size()) || peakNum < 0 ) throw std::invalid_argument("PeaksWorkspace::removePeak(): peakNum is out of range.");
peaks.erase(peaks.begin()+peakNum);
}
//---------------------------------------------------------------------------------------------
/** Add a peak to the list
* @param ipeak :: Peak object to add (copy) into this.
*/
void addPeak(const API::IPeak& ipeak)
{
if (dynamic_cast<const Peak*>(&ipeak))
{
peaks.push_back((const Peak&)ipeak);
}
else
{
peaks.push_back(Peak(ipeak));
}
}
//---------------------------------------------------------------------------------------------
/** Return a reference to the Peak
* @param peakNum :: index of the peak to get.
* @return a reference to a Peak object.
*/
API::IPeak & getPeak(const int peakNum)
{
if (peakNum >= static_cast<int>(peaks.size()) || peakNum < 0 ) throw std::invalid_argument("PeaksWorkspace::getPeak(): peakNum is out of range.");
return peaks[peakNum];
}
//---------------------------------------------------------------------------------------------
/** Create an instance of a Peak
* @param QLabFrame :: Q of the center of the peak, in reciprocal space
* @param detectorDistance :: distance between the sample and the detector.
* @return a pointer to a new Peak object.
*/
API::IPeak* createPeak(Kernel::V3D QLabFrame, double detectorDistance=1.0)
{
return new Peak(this->getInstrument(), QLabFrame, detectorDistance);
}
//---------------------------------------------------------------------------------------------
/** Return a reference to the Peaks vector */
std::vector<Peak> & getPeaks()
{
return peaks;
}
//---------------------------------------------------------------------------------------------
/// Return the memory used in bytes
virtual size_t getMemorySize() const
{
return getNumberPeaks() * sizeof(Peak);
}
int getNumberPeaks() const;
void removePeak(int peakNum);
void addPeak(const API::IPeak& ipeak);
API::IPeak & getPeak(int peakNum);
API::IPeak* createPeak(Kernel::V3D QLabFrame, double detectorDistance=1.0);
std::vector<Peak> & getPeaks();
virtual size_t getMemorySize() const;
// ====================================== ITableWorkspace Methods ==================================
/// Number of columns in the workspace.
......
......@@ -185,6 +185,77 @@ namespace DataObjects
std::stable_sort(peaks.begin(), peaks.end(), comparator);
}
//---------------------------------------------------------------------------------------------
/** @return the number of peaks
*/
int PeaksWorkspace::getNumberPeaks() const
{
return int(peaks.size());
}
//---------------------------------------------------------------------------------------------
/** Removes the indicated peak
* @param peakNum the peak to remove. peakNum starts at 0
*/
void PeaksWorkspace::removePeak(const int peakNum)
{
if (peakNum >= static_cast<int>(peaks.size()) || peakNum < 0 ) throw std::invalid_argument("PeaksWorkspace::removePeak(): peakNum is out of range.");
peaks.erase(peaks.begin()+peakNum);
}
//---------------------------------------------------------------------------------------------
/** Add a peak to the list
* @param ipeak :: Peak object to add (copy) into this.
*/
void PeaksWorkspace::addPeak(const API::IPeak& ipeak)
{
if (dynamic_cast<const Peak*>(&ipeak))
{
peaks.push_back((const Peak&)ipeak);
}
else
{
peaks.push_back(Peak(ipeak));
}
}
//---------------------------------------------------------------------------------------------
/** Return a reference to the Peak
* @param peakNum :: index of the peak to get.
* @return a reference to a Peak object.
*/
API::IPeak & PeaksWorkspace::getPeak(const int peakNum)
{
if (peakNum >= static_cast<int>(peaks.size()) || peakNum < 0 ) throw std::invalid_argument("PeaksWorkspace::getPeak(): peakNum is out of range.");
return peaks[peakNum];
}
//---------------------------------------------------------------------------------------------
/** Create an instance of a Peak
* @param QLabFrame :: Q of the center of the peak, in reciprocal space
* @param detectorDistance :: distance between the sample and the detector.
* @return a pointer to a new Peak object.
*/
API::IPeak* PeaksWorkspace::createPeak(Kernel::V3D QLabFrame, double detectorDistance)
{
return new Peak(this->getInstrument(), QLabFrame, detectorDistance);
}
//---------------------------------------------------------------------------------------------
/** Return a reference to the Peaks vector */
std::vector<Peak> & PeaksWorkspace::getPeaks()
{
return peaks;
}
//---------------------------------------------------------------------------------------------
/// Return the memory used in bytes
size_t PeaksWorkspace::getMemorySize() const
{
return getNumberPeaks() * sizeof(Peak);
}
//---------------------------------------------------------------------------------------------
/** Destructor */
......
......@@ -32,9 +32,9 @@ public:
MOCK_METHOD0(getInstrument, Mantid::Geometry::Instrument_const_sptr ());
MOCK_CONST_METHOD0(clone, Mantid::DataObjects::PeaksWorkspace*());
MOCK_CONST_METHOD0(getNumberPeaks, int());
MOCK_METHOD1(removePeak, void (const int peakNum) );
MOCK_METHOD1(removePeak, void (int peakNum) );
MOCK_METHOD1(addPeak, void (const IPeak& ipeak));
MOCK_METHOD1(getPeak, Mantid::API::IPeak & (const int peakNum));
MOCK_METHOD1(getPeak, Mantid::API::IPeak & (int peakNum));
MOCK_METHOD2(createPeak, Mantid::API::IPeak* (Mantid::Kernel::V3D QLabFrame, double detectorDistance));
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment