Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding bare bone model format manager module
- Loading branch information
1 parent
8a1b3c5
commit 646f87b
Showing
6 changed files
with
128 additions
and
24 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,56 @@ | ||
#include "ModelFormatManager.h" | ||
|
||
#include "itextstream.h" | ||
#include <boost/algorithm/string/case_conv.hpp> | ||
|
||
namespace model | ||
{ | ||
|
||
const std::string& ModelFormatManager::getName() const | ||
{ | ||
static std::string _name(MODULE_MODELFORMATMANAGER); | ||
return _name; | ||
} | ||
|
||
const StringSet& ModelFormatManager::getDependencies() const | ||
{ | ||
static StringSet _dependencies; | ||
return _dependencies; | ||
} | ||
|
||
void ModelFormatManager::initialiseModule(const ApplicationContext& ctx) | ||
{ | ||
rMessage() << getName() << "::initialiseModule called." << std::endl; | ||
} | ||
|
||
void ModelFormatManager::registerExporter(const IModelExporterPtr& exporter) | ||
{ | ||
assert(exporter); | ||
|
||
std::string extension = boost::algorithm::to_upper_copy(exporter->getExtension()); | ||
|
||
if (_exporters.find(extension) != _exporters.end()) | ||
{ | ||
rWarning() << "Cannot register more than one model exporter for extension " << extension << std::endl; | ||
return; | ||
} | ||
|
||
_exporters[extension] = exporter; | ||
} | ||
|
||
void ModelFormatManager::unregisterExporter(const IModelExporterPtr& exporter) | ||
{ | ||
assert(exporter); | ||
|
||
std::string extension = boost::algorithm::to_upper_copy(exporter->getExtension()); | ||
|
||
if (_exporters.find(extension) != _exporters.end()) | ||
{ | ||
_exporters.erase(extension); | ||
return; | ||
} | ||
|
||
rWarning() << "Cannot unregister exporter for extension " << extension << std::endl; | ||
} | ||
|
||
} |
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,26 @@ | ||
#pragma once | ||
|
||
#include <map> | ||
#include "imodel.h" | ||
|
||
namespace model | ||
{ | ||
|
||
class ModelFormatManager : | ||
public IModelFormatManager | ||
{ | ||
private: | ||
// Map file extension to implementation | ||
typedef std::map<std::string, IModelExporterPtr> ExporterMap; | ||
ExporterMap _exporters; | ||
|
||
public: | ||
const std::string& getName() const override; | ||
const StringSet& getDependencies() const override; | ||
void initialiseModule(const ApplicationContext& ctx) override; | ||
|
||
void registerExporter(const IModelExporterPtr& exporter) override; | ||
void unregisterExporter(const IModelExporterPtr& exporter) override; | ||
}; | ||
|
||
} |
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