Skip to content

Commit

Permalink
refs #7200 Created proper factory method for MDBoxes/MDGridBoxes
Browse files Browse the repository at this point in the history
  • Loading branch information
abuts committed May 29, 2013
1 parent 819bac0 commit d0082f8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ namespace MDEvents
template<size_t nd>
static API::IMDNode * createMDBoxFat(API::BoxController *splitter,const std::vector<Mantid::Geometry::MDDimensionExtents<coord_t> > & extentsVector,const uint32_t depth,const size_t nBoxEvents,const size_t boxID);
template<size_t nd>
static API::IMDNode * createMDGridBoxLean(API::BoxController *splitter,const std::vector<Mantid::Geometry::MDDimensionExtents<coord_t> > & extentsVector,const uint32_t depth,const size_t nBoxEvents,const size_t boxID);
static API::IMDNode * createMDGridBoxLean(API::BoxController *splitter,const std::vector<Mantid::Geometry::MDDimensionExtents<coord_t> > & extentsVector,const uint32_t depth,const size_t nBoxEvents=0,const size_t boxID=0);
template<size_t nd>
static API::IMDNode * createMDGridBoxFat(API::BoxController *splitter,const std::vector<Mantid::Geometry::MDDimensionExtents<coord_t> > & extentsVector,const uint32_t depth,const size_t nBoxEvents,const size_t boxID);
static API::IMDNode * createMDGridBoxFat(API::BoxController *splitter,const std::vector<Mantid::Geometry::MDDimensionExtents<coord_t> > & extentsVector,const uint32_t depth,const size_t nBoxEvents=0,const size_t boxID=0);
// 0-dimensions terminator
static API::IMDNode * createMDBoxWrong(API::BoxController *,const std::vector<Mantid::Geometry::MDDimensionExtents<coord_t> > & ,const uint32_t ,const size_t ,const size_t );

Expand Down
39 changes: 34 additions & 5 deletions Code/Mantid/Framework/MDEvents/src/MDEventFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,18 +235,22 @@ namespace Mantid
}

template<size_t nd>
API::IMDNode * createMDGridBoxLean(API::BoxController *splitter,const std::vector<Mantid::Geometry::MDDimensionExtents<coord_t> > & extentsVector,const uint32_t depth,const size_t nBoxEvents,const size_t boxID)
API::IMDNode * MDEventFactory::createMDGridBoxLean(API::BoxController *splitter,const std::vector<Mantid::Geometry::MDDimensionExtents<coord_t> > & extentsVector,const uint32_t depth,
const size_t /*nBoxEvents*/,const size_t /*boxID*/)
{
return new MDGridBox<MDLeanEvent<nd>,nd>(splitter,depth,extentsVector,nBoxEvents,boxID);
return new MDGridBox<MDLeanEvent<nd>,nd>(splitter,depth,extentsVector);
}

template<size_t nd>
static API::IMDNode * createMDGridBoxFat(API::BoxController *splitter,const std::vector<Mantid::Geometry::MDDimensionExtents<coord_t> > & extentsVector,const uint32_t depth,const size_t nBoxEvents,const size_t boxID)
API::IMDNode * MDEventFactory::createMDGridBoxFat(API::BoxController *splitter,const std::vector<Mantid::Geometry::MDDimensionExtents<coord_t> > & extentsVector,const uint32_t depth,
const size_t /*nBoxEvents*/,const size_t /*boxID*/)
{
return new MDGridBox<MDEvent<nd>,nd>(splitter,depth,extentsVector,nBoxEvents,boxID);
return new MDGridBox<MDEvent<nd>,nd>(splitter,depth,extentsVector);
}
//-------------------------------------------------------------- MD BOX constructor wrapper -- END

//------------------------------- FACTORY METHODS ------------------------------------------------------------------------------------------------------------------

/** Create a MDEventWorkspace of the given type
@param nd :: number of dimensions
@param eventType :: string describing the event type (MDEvent or MDLeanEvent)
Expand All @@ -262,7 +266,32 @@ namespace Mantid

return boost::shared_ptr<API::IMDEventWorkspace >(pWs);
}
/** Create a MDBox or MDGridBoxof the given type
@param nDimensions :: number of dimensions
@param Type :: enum descibing the box (MDBox or MDGridBox) and the event type (MDEvent or MDLeanEvent)
@param splitter :: shared pointer to the box controller responsible for splitting boxes. The BC is not incremented as boxes take usual pointer from this pointer
@param extentsVector:: box extents in all n-dimensions (min-max)
@param depth :: the depth of the box within the box tree
@param nBoxEvents :: if defined, specify the memory the box should allocate to accept events -- not used for MDGridBox
@param boxID :: the unique identifier, referencing location of the box in 1D linked list of boxes. -- not used for MDGridBox
@return pointer to the IMDNode with proper box created.
*/

API::IMDNode * MDEventFactory::createBox(size_t nDimensions,MDEventFactory::BoxType Type, API::BoxController_sptr & splitter,
const std::vector<Mantid::Geometry::MDDimensionExtents<coord_t> > & extentsVector,
const uint32_t depth,const size_t nBoxEvents,const size_t boxID)
{

if(nDimensions > MAX_MD_DIMENSIONS_NUM)
throw std::invalid_argument(" there are more dimensions requested then instantiated");

size_t id = nDimensions*MDEventFactory::NumBoxTypes + Type;

return (*(boxCreatorFP[id]))(splitter.get(),extentsVector,depth,nBoxEvents,boxID);
}

//------------------------------- FACTORY METHODS END --------------------------------------------------------------------------------------------------------------

//// the class instantiated by compiler at compilation time and generates the map,
//// between the number of dimensions and the function, which process this number of dimensions
Expand Down Expand Up @@ -302,7 +331,7 @@ namespace Mantid
}
};

//statically instantiate the code, defined by the class above
//statically instantiate the code, defined by the class above and assocoate it with events factory
LOOP<MDEventFactory::MAX_MD_DIMENSIONS_NUM> MDEventFactory::CODE_GENERATOR;

} // namespace Mantid
Expand Down

0 comments on commit d0082f8

Please sign in to comment.