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

#include <SdlCommandParser.h>

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

Public Member Functions

 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

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

Constructor & Destructor Documentation

◆ SdlCommandParser() [1/2]

ph::SdlCommandParser::SdlCommandParser ( TSpanView< const SdlClass * > targetClasses)
explicit

◆ SdlCommandParser() [2/2]

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

◆ ~SdlCommandParser()

ph::SdlCommandParser::~SdlCommandParser ( )
virtualdefault

Member Function Documentation

◆ beginCommand()

virtual bool ph::SdlCommandParser::beginCommand ( ESdlCommandType commandType,
const SdlClass * targetClass,
SdlInputContext * out_ctx )
protectedpure virtual

Called when the parser starts processing a command.

Returns
Whether to generate command for this class.

Implemented in ph::SdlSceneFileReader.

◆ commandVersionSet()

virtual void ph::SdlCommandParser::commandVersionSet ( const SemanticVersion & version,
const SdlInputContext & ctx )
protectedpure virtual

Implemented in ph::SdlSceneFileReader.

◆ createResource()

virtual ISdlResource * ph::SdlCommandParser::createResource ( std::string_view resourceName,
const SdlInputContext & ctx,
ESdlCommandType commandType )
protectedpure virtual

Implemented in ph::SdlSceneFileReader.

◆ endCommand()

virtual void ph::SdlCommandParser::endCommand ( )
protectedpure virtual

Called when the parser finishes processing a command.

Implemented in ph::SdlSceneFileReader.

◆ flush()

void ph::SdlCommandParser::flush ( )

Force the parse of commands that were cached in the parser.

◆ getCommandVersion()

const SemanticVersion & ph::SdlCommandParser::getCommandVersion ( ) const
inline

◆ getPacketInterface()

SdlDataPacketInterface & ph::SdlCommandParser::getPacketInterface ( )

◆ getResource()

virtual ISdlResource * ph::SdlCommandParser::getResource ( std::string_view resourceName,
const SdlInputContext & ctx )
protectedpure virtual

Implemented in ph::SdlSceneFileReader.

◆ getSceneWorkingDirectory()

const Path & ph::SdlCommandParser::getSceneWorkingDirectory ( ) const
inline

◆ initResource()

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

Implemented in ph::SdlSceneFileReader.

◆ numParsedCommands()

std::size_t ph::SdlCommandParser::numParsedCommands ( ) const
inline

◆ numParseErrors()

std::size_t ph::SdlCommandParser::numParseErrors ( ) const
inline

◆ parse()

void ph::SdlCommandParser::parse ( std::string_view rawCommandSegment)

Enters a string and parse it as one or more commands.

The command segment must have valid syntax. The method will potentially cache the command segment in subsequent calls until a command is complete, at which point the command will be parsed and the result will act on the target (e.g., a scene, depending on the implementation).

A valid command segment is a portion of a complete command or a chunk of multiple commands that do not break any keyword or symbol of PSDL. For example, you can break any opening/closing braces, but you cannot break a type name.

Parameters
commandSegmentA valid segment of command.

◆ runExecutor()

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

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.

Implemented in ph::SdlSceneFileReader.

◆ setPacketInterface()

void ph::SdlCommandParser::setPacketInterface ( std::unique_ptr< SdlDataPacketInterface > interface)

◆ setSceneWorkingDirectory()

void ph::SdlCommandParser::setSceneWorkingDirectory ( const Path & directory)

◆ storeNamedDataPacket()

virtual void ph::SdlCommandParser::storeNamedDataPacket ( std::string_view packetName,
const SdlInputClauses & packet,
const SdlInputContext & ctx )
protectedpure virtual

Implemented in ph::SdlSceneFileReader.


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