Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
ph::SdlSceneFileReader Class Reference

Loading utility for renderer scene. Loads .p2 (Photon-v2) file. More...

#include <SdlSceneFileReader.h>

Inheritance diagram for ph::SdlSceneFileReader:
ph::SdlCommandParser

Public Member Functions

 SdlSceneFileReader ()
 
 SdlSceneFileReader (const Path &sceneFile, const Path &sceneWorkingDirectory)
 Creates reader for all engine classes.
 
 SdlSceneFileReader (TSpanView< const SdlClass * > targetClasses, const Path &sceneFile, const Path &sceneWorkingDirectory)
 Creates reader for a custom set of classes.
 
 ~SdlSceneFileReader () override
 
void read (SceneDescription *scene=nullptr)
 
void setSceneFile (Path sceneFile)
 
void setScene (SceneDescription *scene)
 
- Public Member Functions inherited from ph::SdlCommandParser
 SdlCommandParser (TSpanView< const SdlClass * > targetClasses)
 
 SdlCommandParser (TSpanView< const SdlClass * > targetClasses, const Path &sceneWorkingDirectory)
 
virtual ~SdlCommandParser ()
 
void parse (std::string_view rawCommandSegment)
 Enters a string and parse it as one or more commands.
 
void flush ()
 Force the parse of commands that were cached in the parser.
 
void setPacketInterface (std::unique_ptr< SdlDataPacketInterface > interface)
 
void setSceneWorkingDirectory (const Path &directory)
 
SdlDataPacketInterfacegetPacketInterface ()
 
const PathgetSceneWorkingDirectory () const
 
const SemanticVersiongetCommandVersion () const
 
std::size_t numParsedCommands () const
 
std::size_t numParseErrors () const
 

Protected Member Functions

bool beginCommand (ESdlCommandType commandType, const SdlClass *targetClass, SdlInputContext *out_ctx) override
 Called when the parser starts processing a command.
 
void endCommand () override
 Called when the parser finishes processing a command.
 
ISdlResourcecreateResource (std::string_view resourceName, const SdlInputContext &ctx, ESdlCommandType commandType) override
 
void initResource (std::string_view resourceName, ISdlResource *resource, const SdlInputContext &ctx, SdlInputClauses &clauses, ESdlCommandType commandType) override
 
ISdlResourcegetResource (std::string_view resourceName, const SdlInputContext &ctx) override
 
void runExecutor (std::string_view executorName, const SdlInputContext &ctx, ISdlResource *targetResource, SdlInputClauses &clauses, ESdlCommandType commandType) override
 Called when an executor command has been processed and is ready to run.
 
void commandVersionSet (const SemanticVersion &version, const SdlInputContext &ctx) override
 
void storeNamedDataPacket (std::string_view packetName, const SdlInputClauses &packet, const SdlInputContext &ctx) override
 

Detailed Description

Loading utility for renderer scene. Loads .p2 (Photon-v2) file.

Constructor & Destructor Documentation

◆ SdlSceneFileReader() [1/3]

ph::SdlSceneFileReader::SdlSceneFileReader ( )

◆ SdlSceneFileReader() [2/3]

ph::SdlSceneFileReader::SdlSceneFileReader ( const Path & sceneFile,
const Path & sceneWorkingDirectory )

Creates reader for all engine classes.

◆ SdlSceneFileReader() [3/3]

ph::SdlSceneFileReader::SdlSceneFileReader ( TSpanView< const SdlClass * > targetClasses,
const Path & sceneFile,
const Path & sceneWorkingDirectory )

Creates reader for a custom set of classes.

◆ ~SdlSceneFileReader()

ph::SdlSceneFileReader::~SdlSceneFileReader ( )
overridedefault

Member Function Documentation

◆ beginCommand()

bool ph::SdlSceneFileReader::beginCommand ( ESdlCommandType commandType,
const SdlClass * targetClass,
SdlInputContext * out_ctx )
overrideprotectedvirtual

Called when the parser starts processing a command.

Returns
Whether to generate command for this class.

Implements ph::SdlCommandParser.

◆ commandVersionSet()

void ph::SdlSceneFileReader::commandVersionSet ( const SemanticVersion & version,
const SdlInputContext & ctx )
overrideprotectedvirtual

Implements ph::SdlCommandParser.

◆ createResource()

ISdlResource * ph::SdlSceneFileReader::createResource ( std::string_view resourceName,
const SdlInputContext & ctx,
ESdlCommandType commandType )
overrideprotectedvirtual

Implements ph::SdlCommandParser.

◆ endCommand()

void ph::SdlSceneFileReader::endCommand ( )
overrideprotectedvirtual

Called when the parser finishes processing a command.

Implements ph::SdlCommandParser.

◆ getResource()

ISdlResource * ph::SdlSceneFileReader::getResource ( std::string_view resourceName,
const SdlInputContext & ctx )
overrideprotectedvirtual

Implements ph::SdlCommandParser.

◆ initResource()

void ph::SdlSceneFileReader::initResource ( std::string_view resourceName,
ISdlResource * resource,
const SdlInputContext & ctx,
SdlInputClauses & clauses,
ESdlCommandType commandType )
overrideprotectedvirtual

Implements ph::SdlCommandParser.

◆ read()

void ph::SdlSceneFileReader::read ( SceneDescription * scene = nullptr)
Parameters
[in,out]sceneThe target for parsed results. Effectively set current scene to scene then start reading. If scene was null, read to the current scene instead.

◆ runExecutor()

void ph::SdlSceneFileReader::runExecutor ( std::string_view executorName,
const SdlInputContext & ctx,
ISdlResource * targetResource,
SdlInputClauses & clauses,
ESdlCommandType commandType )
overrideprotectedvirtual

Called when an executor command has been processed and is ready to run.

A side note for SDL grammer: An executor may be called with an explicit class type, or with the type part omitted and let the class type deduced from the reference. Calling with explicit class type has potential performance benefit as the parser may not need to search the full class hierarchy to find the target executor to call (deducing from the reference itself always yield the exact, most derived type); however, calling with explicit class type may miss the derived implementation if the executor is overridden (the parser will only search from the class type you specified).

For implementations, obtaining the target class from context object should be preferred over obtaining from the resource itself, since an executor may be called with an explicit class and context object has this information.

Implements ph::SdlCommandParser.

◆ setScene()

void ph::SdlSceneFileReader::setScene ( SceneDescription * scene)

The reader takes a pointer to scene and cache it since a possible use case is to treat the reader as a command interpreter. Not specifying a scene on each method call makes a cleaner interface.

Parameters
[in,out]sceneThe target for parsed results. scene will be the current scene.

◆ setSceneFile()

void ph::SdlSceneFileReader::setSceneFile ( Path sceneFile)

◆ storeNamedDataPacket()

void ph::SdlSceneFileReader::storeNamedDataPacket ( std::string_view packetName,
const SdlInputClauses & packet,
const SdlInputContext & ctx )
overrideprotectedvirtual

Implements ph::SdlCommandParser.


The documentation for this class was generated from the following files: