PeriDyno 1.2.1
Loading...
Searching...
No Matches
SceneLoaderFactory.h
Go to the documentation of this file.
1#pragma once
2#include "SceneGraph.h"
3#include <variant>
4
5namespace dyno {
6
8 {
9 public:
10 using LoadResult = std::variant<std::shared_ptr<SceneGraph>, std::string>;
11
12 virtual LoadResult load(const std::string filename) { return "null"; }
13
14 virtual bool save(std::shared_ptr<SceneGraph> scn, const std::string filename) { return false; }
15
16 virtual bool canLoadFileByName(const std::string filename) {
17 std::string str = filename;
18 std::string::size_type pos = str.find_last_of('.');
19 if (pos == std::string::npos)
20 return false; // no extension
21
22 return canLoadFileByExtension(str.substr(pos + 1));
23 }
24
25 virtual bool canLoadFileByExtension(const std::string extension) { return false; }
26 };
27
29 {
30 public:
31 typedef std::vector<SceneLoader*> SceneLoaderList;
32
35
36 public:
38 SceneLoader* getEntryByFileExtension(std::string extension);
39
41 SceneLoader* getEntryByFileName(std::string filename);
42
45
48
49 private:
51
54 };
55
56
57}
static SceneLoaderFactory & getInstance()
Get the ObjectFactory singleton instance.
std::vector< SceneLoader * > SceneLoaderList
SceneLoader * getEntryByFileExtension(std::string extension)
Get an entry given a file extension.
SceneLoader * addEntry(SceneLoader *loader)
Add a scene loader.
SceneLoader * getEntryByFileName(std::string filename)
Get an entry given a file name.
SceneLoaderList * getEntryList()
Get the list of loaders.
SceneLoaderList m_loaders
Main class registry.
virtual LoadResult load(const std::string filename)
virtual bool save(std::shared_ptr< SceneGraph > scn, const std::string filename)
virtual bool canLoadFileByExtension(const std::string extension)
virtual bool canLoadFileByName(const std::string filename)
std::variant< std::shared_ptr< SceneGraph >, std::string > LoadResult
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25