-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add (1) abstract class ISplittersWorkspace for python. (2) SplitterWorkspace inheriting from TableWorkspace.
- Loading branch information
Showing
8 changed files
with
360 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
Code/Mantid/Framework/API/inc/MantidAPI/ISplittersWorkspace.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#ifndef MANTID_API_ISPLITTERSWORKSPACE_H_ | ||
#define MANTID_API_ISPLITTERSWORKSPACE_H_ | ||
|
||
#include "MantidKernel/System.h" | ||
#include "MantidAPI/ITableWorkspace.h" | ||
#include "MantidKernel/TimeSplitter.h" | ||
|
||
|
||
namespace Mantid | ||
{ | ||
namespace API | ||
{ | ||
|
||
/** ISplittersWorkspace : Workspace to contain splitters for event filtering. | ||
* It inherits from ITableWorkspace | ||
@date 2012-04-03 | ||
Copyright © 2012 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory | ||
This file is part of Mantid. | ||
Mantid is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 3 of the License, or | ||
(at your option) any later version. | ||
Mantid is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid> | ||
Code Documentation is available at: <http://doxygen.mantidproject.org> | ||
*/ | ||
class DLLExport ISplittersWorkspace : virtual public API::ITableWorkspace | ||
{ | ||
public: | ||
/* | ||
* Constructor | ||
*/ | ||
ISplittersWorkspace() | ||
:API::ITableWorkspace() | ||
{ | ||
} | ||
|
||
/* | ||
* Destructor | ||
*/ | ||
virtual ~ISplittersWorkspace(); | ||
|
||
/* | ||
* Add a time splitter to table workspace | ||
*/ | ||
virtual void addSplitter(Kernel::SplittingInterval splitter) = 0; | ||
|
||
/* | ||
* Get the corresponding workspace index of a time | ||
* Input time must the total nanoseconds of the absolute time from 1990.00.00 | ||
*/ | ||
virtual Kernel::SplittingInterval getSplitter(size_t index) = 0; | ||
|
||
/* | ||
* Get number of splitters | ||
*/ | ||
virtual size_t getNumberSplitters() = 0; | ||
|
||
/* | ||
* Remove one entry of a splitter | ||
*/ | ||
virtual bool removeSplitter(size_t splitterindex) = 0; | ||
|
||
}; | ||
|
||
|
||
} // namespace API | ||
} // namespace Mantid | ||
|
||
#endif /* MANTID_API_ISPLITTERSWORKSPACE_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//---------------------------------------------------------------------- | ||
// Includes | ||
//---------------------------------------------------------------------- | ||
#include "MantidAPI/ISplittersWorkspace.h" | ||
|
||
namespace Mantid | ||
{ | ||
namespace API | ||
{ | ||
|
||
using namespace Kernel; | ||
|
||
ISplittersWorkspace::~ISplittersWorkspace() {} | ||
|
||
|
||
} //API namespace | ||
|
||
} //Mantid namespace | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
Code/Mantid/Framework/DataObjects/inc/MantidDataObjects/SplittersWorkspace.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#ifndef MANTID_DATAOBJECTS_SPLITTERSWORKSPACE_H_ | ||
#define MANTID_DATAOBJECTS_SPLITTERSWORKSPACE_H_ | ||
|
||
#include "MantidKernel/System.h" | ||
#include "MantidAPI/ISplittersWorkspace.h" | ||
#include "MantidKernel/TimeSplitter.h" | ||
#include "MantidDataObjects/TableWorkspace.h" | ||
|
||
|
||
namespace Mantid | ||
{ | ||
namespace DataObjects | ||
{ | ||
|
||
/** SplittersWorkspace : A TableWorkspace to contain TimeSplitters. | ||
It will be used as an input for FilterEvents, which is the ultimate method for event filtering. | ||
There can be various algorithms to generate an object like this. | ||
A SplittersWorkspace contains 3 columns as int64, int64 and int32 to denote | ||
(1) splitter start time (2) splitter end time and (3) group workspace index | ||
@date 2012-04-03 | ||
Copyright © 2012 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory | ||
This file is part of Mantid. | ||
Mantid is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 3 of the License, or | ||
(at your option) any later version. | ||
Mantid is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid> | ||
Code Documentation is available at: <http://doxygen.mantidproject.org> | ||
*/ | ||
class DLLExport SplittersWorkspace : public API::ISplittersWorkspace, public DataObjects::TableWorkspace | ||
{ | ||
public: | ||
SplittersWorkspace(); | ||
virtual ~SplittersWorkspace(); | ||
|
||
void addSplitter(Kernel::SplittingInterval splitter); | ||
|
||
Kernel::SplittingInterval getSplitter(size_t index); | ||
|
||
size_t getNumberSplitters(); | ||
|
||
bool removeSplitter(unsigned long); | ||
|
||
}; | ||
|
||
|
||
} // namespace DataObjects | ||
} // namespace Mantid | ||
|
||
#endif /* MANTID_DATAOBJECTS_SPLITTERSWORKSPACE_H_ */ |
87 changes: 87 additions & 0 deletions
87
Code/Mantid/Framework/DataObjects/src/SplittersWorkspace.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#include "MantidDataObjects/SplittersWorkspace.h" | ||
#include "MantidKernel/System.h" | ||
#include "MantidAPI/Column.h" | ||
#include "MantidAPI/TableRow.h" | ||
|
||
using namespace Mantid::Kernel; | ||
using namespace Mantid::API; | ||
|
||
namespace Mantid | ||
{ | ||
namespace DataObjects | ||
{ | ||
|
||
Kernel::Logger& mg_log = Kernel::Logger::get("ITableWorkspace"); | ||
|
||
//---------------------------------------------------------------------------------------------- | ||
/** Constructor | ||
*/ | ||
SplittersWorkspace::SplittersWorkspace() | ||
{ | ||
this->addColumn("long64", "start"); | ||
this->addColumn("long64", "stop"); | ||
this->addColumn("int", "workspacegroup"); | ||
} | ||
|
||
//---------------------------------------------------------------------------------------------- | ||
/** Destructor | ||
*/ | ||
SplittersWorkspace::~SplittersWorkspace() | ||
{ | ||
} | ||
|
||
/* | ||
* Add a Splitter to | ||
*/ | ||
void SplittersWorkspace::addSplitter(Mantid::Kernel::SplittingInterval splitter) | ||
{ | ||
Mantid::API::TableRow row = this->appendRow(); | ||
row << splitter.start().totalNanoseconds(); | ||
row << splitter.stop().totalNanoseconds(); | ||
row << splitter.index(); | ||
|
||
return; | ||
} | ||
|
||
Kernel::SplittingInterval SplittersWorkspace::getSplitter(size_t index) | ||
{ | ||
API::Column_const_sptr column = this->getColumn("start"); | ||
API::TableRow row = this->getRow(index); | ||
int64_t start, stop; | ||
int wsgroup; | ||
row >> start; | ||
row >> stop; | ||
row >> wsgroup; | ||
|
||
Kernel::SplittingInterval splitter(Kernel::DateAndTime(start), Kernel::DateAndTime(stop), wsgroup); | ||
|
||
return splitter; | ||
} | ||
|
||
size_t SplittersWorkspace::getNumberSplitters() | ||
{ | ||
return this->rowCount(); | ||
} | ||
|
||
|
||
bool SplittersWorkspace::removeSplitter(unsigned long index) | ||
{ | ||
bool removed; | ||
if (index >= this->rowCount()) | ||
{ | ||
mg_log.error() << "Try to delete a non-existing splitter " << index << std::endl; | ||
removed = false; | ||
} | ||
else | ||
{ | ||
this->removeRow(index); | ||
removed = true; | ||
} | ||
|
||
return removed; | ||
} | ||
|
||
|
||
|
||
} // namespace Mantid | ||
} // namespace DataObjects |
Oops, something went wrong.