Asset.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_FRAMEWORK_ASSET_H
#define SURGSIM_FRAMEWORK_ASSET_H
#include <string>
#include "SurgSim/Framework/ObjectFactory.h"
#include "SurgSim/Framework/Accessible.h"
namespace SurgSim
{
namespace Framework
{
class Accessible;
class ApplicationData;
class AssetTest;
class Asset : virtual public Accessible, public FactoryBase<Asset>
{
friend AssetTest;
public:
Asset();
Asset(const Asset& rhs);
virtual ~Asset();
void load(const std::string& fileName, const SurgSim::Framework::ApplicationData& data);
void load(const std::string& fileName);
std::string getFileName() const;
virtual std::string getClassName() const = 0;
protected:
virtual bool doLoad(const std::string& filePath) = 0;
private:
void serializeFileName(SurgSim::Framework::Accessible* accessible);
std::string m_fileName;
};
} // namespace Framework
} // namespace SurgSim
#endif // SURGSIM_FRAMEWORK_ASSET_H
SurgSim::Framework::Asset::serializeFileName
void serializeFileName(SurgSim::Framework::Accessible *accessible)
Wrap the registration calls for the filename property, which is more complicated due to the overloade...
Definition: Asset.cpp:63
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Framework::Asset
This class is used to facilitate file loading.
Definition: Asset.h:39
SurgSim::Framework::ApplicationData
Enable searching for files in a given list of paths, give access to the current directory and wrap bo...
Definition: ApplicationData.h:39
SurgSim::Framework::Asset::AssetTest
friend AssetTest
Definition: Asset.h:41
Accessible.h
SurgSim::Framework::Asset::load
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
ObjectFactory.h
SurgSim::Framework::Asset::getFileName
std::string getFileName() const
Return the name of file loaded by this class.
Definition: Asset.cpp:58
SurgSim::Framework::Asset::doLoad
virtual bool doLoad(const std::string &filePath)=0
Derived classes will overwrite this method to do actual loading.
SurgSim::Framework::Asset::Asset
Asset()
Constructor.
Definition: Asset.cpp:28
SurgSim::Framework::Asset::m_fileName
std::string m_fileName
Name of the file to be loaded.
Definition: Asset.h:87
SurgSim::Framework::Asset::~Asset
virtual ~Asset()
Destructor.
Definition: Asset.cpp:38
SurgSim::Framework::Accessible
Mixin class for enabling a property system on OSS classes, the instance still needs to initialize pro...
Definition: Accessible.h:37
SurgSim::Framework::Asset::getClassName
virtual std::string getClassName() const =0
Support serialization with a classname.
SurgSim::Framework::FactoryBase
CRTP Base class to implement Object Factory functionality on a base class, use this rather than writi...
Definition: ObjectFactory.h:122