Cafu Engine
MaterialManagerImpl.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 /***************************************/
8 /*** Material Manager Implementation ***/
9 /***************************************/
10 
11 #ifndef CAFU_MATSYS_MATERIAL_MANAGER_IMPLEMENTATION_HPP_INCLUDED
12 #define CAFU_MATSYS_MATERIAL_MANAGER_IMPLEMENTATION_HPP_INCLUDED
13 
14 #include "MaterialManager.hpp"
15 
16 #include <map>
17 
18 
19 class TableT;
20 
21 
22 /// This class implements the MaterialManagerI interface.
24 {
25  public:
26 
29 
30  /// Registers a copy of the given material \c Mat and returns a pointer to the registered copy.
31  /// If a material with the same name \c Mat.Name is already registered with the material manager,
32  /// \c Mat is not registered, but a pointer to the already registered instance with the same name is returned
33  /// (use HasMaterial() in advance to unambigiously distingush between the two cases).
34  ///
35  /// @param Mat The material of which a copy is to be registered with the material manager.
36  /// @returns A pointer to the registered material instance (or a previously existing instance with the same name).
38 
39 
40  // The MaterialManagerI interface.
41  ArrayT<MaterialT*> RegisterMaterialScript(const std::string& FileName, const std::string& BaseDir);
42  ArrayT<MaterialT*> RegisterMaterialScriptsInDir(const std::string& DirName, const std::string& BaseDir, const bool Recurse=true);
43  const std::map<std::string, MaterialT*>& GetAllMaterials() const { return Materials; }
44  bool HasMaterial(const std::string& MaterialName) const;
45  MaterialT* GetMaterial(const std::string& MaterialName) const;
46  // void ClearAllMaterials();
47 
48 
49  private:
50 
51  MaterialManagerImplT(const MaterialManagerImplT&); // Use of the Copy Constructor is not allowed.
52  void operator = (const MaterialManagerImplT&); // Use of the Assignment Operator is not allowed.
53 
54  ArrayT<std::string> MaterialScriptFileNames;
55  ArrayT<TableT*> Tables;
56  std::map<std::string, MaterialT*> Materials;
57 };
58 
59 #endif
MaterialT * RegisterMaterial(const MaterialT &Mat)
Registers a copy of the given material Mat and returns a pointer to the registered copy...
Definition: MaterialManagerImpl.cpp:152
Definition: Expression.hpp:17
This class represents a surface material ("A datastructural representation of a scripts material def...
Definition: Material.hpp:22
This class implements the MaterialManagerI interface.
Definition: MaterialManagerImpl.hpp:23
ArrayT< MaterialT * > RegisterMaterialScript(const std::string &FileName, const std::string &BaseDir)
Registers a material script file.
Definition: MaterialManagerImpl.cpp:167
This is an interface to the material manager.
Definition: MaterialManager.hpp:31
MaterialT * GetMaterial(const std::string &MaterialName) const
Returns a material by its name.
Definition: MaterialManagerImpl.cpp:346
ArrayT< MaterialT * > RegisterMaterialScriptsInDir(const std::string &DirName, const std::string &BaseDir, const bool Recurse=true)
Registers all ".cmat" files in a directory as material script files.
Definition: MaterialManagerImpl.cpp:248
bool HasMaterial(const std::string &MaterialName) const
Returns whether the material with the given name is registered with the material manager, i.e. if a call to GetMaterial(MaterialName) will return successfully.
Definition: MaterialManagerImpl.cpp:338
const std::map< std::string, MaterialT * > & GetAllMaterials() const
Returns all the materials registered so far.
Definition: MaterialManagerImpl.hpp:43