Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5128: Add IManipulatorManager interface, since I want the manipulato…
…r algorithms to be part of the core module.
- Loading branch information
1 parent
bdff5ea
commit 80473fb
Showing
5 changed files
with
97 additions
and
0 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
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
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,66 @@ | ||
#include "imanipulator.h" | ||
|
||
#include <map> | ||
#include "module/StaticModule.h" | ||
#include "string/convert.h" | ||
|
||
namespace selection | ||
{ | ||
|
||
class ManipulatorManager : | ||
public IManipulatorManager | ||
{ | ||
private: | ||
using ManipulatorsByType = std::map<IManipulator::Type, std::function<IManipulator::Ptr()>>; | ||
std::map<IManipulator::Context, ManipulatorsByType> _manipulatorsByContext; | ||
|
||
public: | ||
|
||
IManipulator::Ptr createManipulator(IManipulator::Context context, IManipulator::Type type) override | ||
{ | ||
if (_manipulatorsByContext.count(context) == 0) | ||
{ | ||
throw std::runtime_error("Manipulator context not known: " + string::to_string(static_cast<int>(context))); | ||
} | ||
|
||
auto existing = _manipulatorsByContext[context].find(type); | ||
|
||
if (existing == _manipulatorsByContext[context].end()) | ||
{ | ||
throw std::runtime_error("Manipulator type not known: " + string::to_string(static_cast<int>(type))); | ||
} | ||
|
||
return existing->second(); | ||
} | ||
|
||
const std::string& getName() const | ||
{ | ||
static std::string _name(MODULE_MANIPULATORMANAGER); | ||
return _name; | ||
} | ||
|
||
const StringSet& getDependencies() const | ||
{ | ||
static StringSet _dependencies; | ||
return _dependencies; | ||
} | ||
|
||
void initialiseModule(const IApplicationContext& ctx) | ||
{ | ||
rMessage() << getName() << "::initialiseModule called." << std::endl; | ||
|
||
_manipulatorsByContext.emplace(IManipulator::Context::Scene, ManipulatorsByType()); | ||
_manipulatorsByContext.emplace(IManipulator::Context::TextureTool, ManipulatorsByType()); | ||
|
||
// TODO | ||
} | ||
|
||
void shutdownModule() | ||
{ | ||
_manipulatorsByContext.clear(); | ||
} | ||
}; | ||
|
||
module::StaticModule<ManipulatorManager> _manipulatorManagerInstance; | ||
|
||
} |
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
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