Skip to main content

Timeline for Refactoring a god Manager class

Current License: CC BY-SA 3.0

7 events
when toggle format what by license comment
Aug 25, 2015 at 1:33 comment added Dominique McDonnell Which is what I thought in the beginning. You can use template specialisation to avoid the casts, though it does lead to code duplication, it will be the most efficient. How to do it is off topic for Programmers, and you should ask that question (not the question you asked above) on StackOverflow.
Aug 24, 2015 at 17:13 comment added 1v0 yes or lets even say simple, I have an std::map<BufferID, Buffer<int>> intBufferDict and and std::map<BufferID, Buffer<double>> doubleBufferDict; and three BufferIDs BuffInt, BuffInt2, BuffDouble and now if I want a function getBuffer<int>(BuffInt2) which returns a Buffer storing ints.
Aug 24, 2015 at 16:52 comment added Dominique McDonnell So if I get this right you have an array( or vector etc) of std::maps of some generic base?
Aug 24, 2015 at 16:05 comment added 1v0 Thanks for your comment. The BufferMap just consist of N different std::maps, one for each type 1...N of Buffers. The problem is that I would have to write a function Buffer<T> getBuffer<T>(BufferID) in the BufferMap class which accesses the correct std::map but I don't know how to do this without dynamic_cast
Aug 24, 2015 at 15:59 comment added Dominique McDonnell It's very hard to answer as I don't know the implementation details of your BufferMap, but from your description I expected the buffers to be separate and it would be pretty simple to create specialisations of a templated method which selected the data from the correct buffer. If that isn't applicable, could you give some more detail?
Aug 24, 2015 at 15:44 comment added 1v0 Thank you for your answer. Good idea with splitting the BufferMap and the BufferIntervalCalculator. But the main question remains: In bufferIntervalCalculator.calculateInterval<TypeJInterval>, one needs to access the map containing buffers of type J, and if we dont want to use dynamic_cast how would you do this?
Aug 21, 2015 at 3:23 history answered Dominique McDonnell CC BY-SA 3.0