Skip to content

Commit

Permalink
Refs #8550. Make the column class templated.
Browse files Browse the repository at this point in the history
Instantiated for int for now and done a simple test.
  • Loading branch information
arturbekasov committed Dec 4, 2013
1 parent 68619d6 commit 787b53b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
Expand Up @@ -35,18 +35,18 @@ namespace DataObjects
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/

template <class Type>
class DLLExport VectorColumn : public Column
{
public:
VectorColumn()
{
// TODO: implement
m_type = typeName();
}

virtual ~VectorColumn()
{
// TODO: implement
}
{}

/// Number of individual elements in the column
virtual size_t size() const
Expand All @@ -57,13 +57,13 @@ namespace DataObjects
/// Returns typeid for the data in the column
virtual const std::type_info& get_type_info() const
{
return typeid(int); // TODO: for now
return typeid( std::vector<Type> );
}

/// Returns typeid for the pointer type to the data element in the column
virtual const std::type_info& get_pointer_type_info() const
{
return typeid(int); // TODO: for now
return typeid( std::vector<Type>* );
}

/// Print specified item to the stream
Expand All @@ -87,13 +87,13 @@ namespace DataObjects
/// Overall memory size taken by the column
virtual long int sizeOfData() const
{
return 0; // TODO: for now
// TODO: implement
}

/// Create another copy of the column
virtual VectorColumn* clone() const
{
return NULL; // TODO: for now
// TODO: implement
}

/// Cast to double
Expand Down Expand Up @@ -129,22 +129,28 @@ namespace DataObjects
/// Pointer to a data element
virtual void* void_pointer(size_t index)
{
return NULL;
// TODO: implement
}

/// Pointer to a data element
virtual const void* void_pointer(size_t index) const
{
return NULL;
// TODO: implement
}

private:
/// All the vectors stored
std::vector< std::vector<int> > m_data;
std::vector< std::vector<Type> > m_data;

/// Returns the name of the column with the given type. Is specialized using DECLARE_VECTORCOLUMN
std::string typeName();
};


} // namespace DataObjects
} // namespace Mantid

#define DECLARE_VECTORCOLUMN(Type,TypeName) \
template<> std::string VectorColumn<Type>::typeName() { return #TypeName; };

#endif /* MANTID_DATAOBJECTS_VECTORCOLUMN_H_ */
1 change: 1 addition & 0 deletions Code/Mantid/Framework/DataObjects/src/VectorColumn.cpp
Expand Up @@ -4,5 +4,6 @@ namespace Mantid
{
namespace DataObjects
{
DECLARE_VECTORCOLUMN(int, vector_int);
} // namespace DataObjects
} // namespace Mantid
8 changes: 4 additions & 4 deletions Code/Mantid/Framework/DataObjects/test/VectorColumnTest.h
Expand Up @@ -15,14 +15,14 @@ class VectorColumnTest : public CxxTest::TestSuite
static VectorColumnTest *createSuite() { return new VectorColumnTest(); }
static void destroySuite( VectorColumnTest *suite ) { delete suite; }


void test_Something()
void test_construction()
{
TSM_ASSERT( "You forgot to write a test!", 0);
VectorColumn<int> col;
TS_ASSERT_EQUALS( col.type(), "vector_int");
}


};


#endif /* MANTID_DATAOBJECTS_VECTORCOLUMNTEST_H_ */
#endif /* MANTID_DATAOBJECTS_VECTORCOLUMNTEST_H_ */

0 comments on commit 787b53b

Please sign in to comment.