Skip to content

Commit

Permalink
Implement relevant PeakColumn methods from table API. Refs #5729
Browse files Browse the repository at this point in the history
  • Loading branch information
martyngigg committed Nov 26, 2012
1 parent 17f9805 commit 34c4b58
Show file tree
Hide file tree
Showing 6 changed files with 333 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "MantidAPI/Column.h"
#include "MantidDataObjects/Peak.h"

#include <boost/variant.hpp>

namespace Mantid
{
Expand All @@ -24,13 +25,14 @@ namespace DataObjects
{

public:
PeakColumn(std::vector<Peak> & peaks, std::string name);
/// Construct a column with a reference to the peaks list, a name & type
PeakColumn(std::vector<Peak> & peaks, const std::string & name);
virtual ~PeakColumn();


/// Number of individual elements in the column.
virtual size_t size() const
{ return peaks.size(); }
{ return m_peaks.size(); }

/// Returns typeid for the data in the column
virtual const std::type_info& get_type_info()const;
Expand Down Expand Up @@ -74,7 +76,12 @@ namespace DataObjects

private:
/// Reference to the peaks object saved in the PeaksWorkspace.
std::vector<Peak> & peaks;
std::vector<Peak> & m_peaks;

/// Type of the row cache value
typedef boost::variant<double,int,std::string,Kernel::V3D> CacheValueType;
///
mutable std::list<CacheValueType> m_oldRows;
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,12 @@ namespace DataObjects
{
return this->columnNames;
}


/// This is always threadsafe
virtual bool threadSafe() const { return true;}

// --- Nexus Methods ---
// Save to Nexus
void saveNexus(::NeXus::File * file ) const;

private:
/** Vector of Peak contained within. */
Expand All @@ -159,19 +161,19 @@ namespace DataObjects
/** Column names */
std::vector<std::string> columnNames;

/// Initialize the table structure
void initColumns();


public:
/// Adds a new PeakColumn of the given type
void addPeakColumn(const std::string& name);

// ====================================== ITableWorkspace Methods ==================================

virtual bool addColumn(const std::string& /*type*/, const std::string& /*name*/);

// ===== Methods that are not implemented (read-only table) ==========
virtual bool addColumn(const std::string& /*type*/, const std::string& /*name*/)
{ throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace structure is read-only. Cannot add column."); }

virtual bool addColumns(const std::string& /*type*/, const std::string& /*name*/, size_t /*n*/)
{ throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace structure is read-only. Cannot add column."); }
{ throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace structure is read-only. Cannot add columns."); }

virtual void removeColumn( const std::string& /*name*/)
{ throw Mantid::Kernel::Exception::NotImplementedError("PeaksWorkspace structure is read-only. Cannot remove column."); }
Expand Down Expand Up @@ -206,9 +208,6 @@ namespace DataObjects

// ====================================== End ITableWorkspace Methods ==================================

// --- Nexus Methods ---
// Save to Nexus
void saveNexus(::NeXus::File * file ) const;
// adapter for logs() function, which create reference to this class itself and does not allow to delete the shared pointers,
// returned by logs() function when they go out of scope
API::LogManager_sptr m_logCash;
Expand All @@ -222,11 +221,7 @@ namespace DataObjects
typedef boost::shared_ptr<const PeaksWorkspace> PeaksWorkspace_const_sptr;



}
}
#endif




0 comments on commit 34c4b58

Please sign in to comment.