opensurgsim
Asset.h
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_FRAMEWORK_ASSET_H
17 #define SURGSIM_FRAMEWORK_ASSET_H
18 
19 #include <string>
20 #include "SurgSim/Framework/ObjectFactory.h"
21 #include "SurgSim/Framework/Accessible.h"
22 
23 namespace SurgSim
24 {
25 namespace Framework
26 {
27 class Accessible;
28 class ApplicationData;
29 class AssetTest;
30 
39 class Asset : virtual public Accessible, public FactoryBase<Asset>
40 {
41  friend AssetTest;
42 public:
44  Asset();
45 
47  Asset(const Asset& rhs);
48 
50  virtual ~Asset();
51 
59  void load(const std::string& fileName, const SurgSim::Framework::ApplicationData& data);
60 
63  void load(const std::string& fileName);
64 
67  std::string getFileName() const;
68 
71  virtual std::string getClassName() const = 0;
72 
73 protected:
78  virtual bool doLoad(const std::string& filePath) = 0;
79 
80 private:
84  void serializeFileName(SurgSim::Framework::Accessible* accessible);
85 
87  std::string m_fileName;
88 };
89 
90 } // namespace Framework
91 } // namespace SurgSim
92 
93 #endif // SURGSIM_FRAMEWORK_ASSET_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
This class is used to facilitate file loading.
Definition: Asset.h:39
Enable searching for files in a given list of paths, give access to the current directory and wrap bo...
Definition: ApplicationData.h:39
void load(const std::string &fileName, const SurgSim::Framework::ApplicationData &data)
Load a file with given name using &#39;data&#39; as look up path(s).
Definition: Asset.cpp:42
Definition: AssetTests.cpp:54
std::string getFileName() const
Return the name of file loaded by this class.
Definition: Asset.cpp:58
virtual bool doLoad(const std::string &filePath)=0
Derived classes will overwrite this method to do actual loading.
Asset()
Constructor.
Definition: Asset.cpp:28
virtual ~Asset()
Destructor.
Definition: Asset.cpp:38
Mixin class for enabling a property system on OSS classes, the instance still needs to initialize pro...
Definition: Accessible.h:37
virtual std::string getClassName() const =0
Support serialization with a classname.
CRTP Base class to implement Object Factory functionality on a base class, use this rather than writi...
Definition: ObjectFactory.h:122