stmm-games-doc  0.32.0
Public Member Functions | List of all members
stmg::XmlCumulCmpEventParser Class Reference
Inheritance diagram for stmg::XmlCumulCmpEventParser:
Inheritance graph
[legend]

Public Member Functions

 XmlCumulCmpEventParser ()
 
EventparseEvent (GameCtx &oCtx, const xmlpp::Element *p0Element) override
 Parse and create an event instance. More...
 
int32_t parseEventMsgName (ConditionalCtx &oCtx, const xmlpp::Element *p0Element, const std::string &sAttr, const std::string &sMsgName) override
 Returns event type's msg value from msg name. More...
 
int32_t parseEventListenerGroupName (GameCtx &oCtx, const xmlpp::Element *p0Element, const std::string &sAttr, const std::string &sListenerGroupName) override
 Returns event type listener group value from name. More...
 
- Public Member Functions inherited from stmg::XmlEventParser
virtual ~XmlEventParser ()=default
 
 XmlEventParser (const std::string &sEventName)
 Constructor. More...
 
const std::string & getEventName () const
 The event name. More...
 
virtual void recycleEvents (std::unique_ptr< Event > &refEvent)
 Recycle the event if it is of a type created by this instance. More...
 

Additional Inherited Members

- Protected Member Functions inherited from stmg::XmlEventParser
bool getBlock (GameCtx &oCtx, const std::string &sName, Block &oBlock)
 Return named block. More...
 
EventparseChildEvent (GameCtx &oCtx, const xmlpp::Element *p0Element)
 Parses an event and adds it to the level. More...
 
void parseEventBase (GameCtx &oCtx, const xmlpp::Element *p0Element, Event::Init &oInit)
 Parse event base. More...
 
EventintegrateAndAdd (GameCtx &oCtx, unique_ptr< Event > refEvent, const xmlpp::Element *p0Element)
 Integrate the event add to level. More...
 
int32_t parseEventAttrRepeat (GameCtx &oCtx, const xmlpp::Element *p0EventElement)
 Helper function for the 'repeat' attribute. More...
 
int32_t parseEventAttrStep (GameCtx &oCtx, const xmlpp::Element *p0EventElement)
 Helper function for the 'step' attribute. More...
 
int32_t parseEventAttrRandomProb (GameCtx &oCtx, const xmlpp::Element *p0EventElement)
 Helper function for the 'prob' attribute. More...
 
bool isReservedChildElementOfEvent (const std::string &sElementName) const
 Tells whether a child element name of Event is reserved. More...
 
XmlConditionalParsergetXmlConditionalParser ()
 Get the conditional parser. More...
 
XmlTraitsParsergetXmlTraitsParser ()
 Get the traits parser. More...
 

Constructor & Destructor Documentation

◆ XmlCumulCmpEventParser()

stmg::XmlCumulCmpEventParser::XmlCumulCmpEventParser ( )

Member Function Documentation

◆ parseEvent()

Event* stmg::XmlCumulCmpEventParser::parseEvent ( GameCtx oCtx,
const xmlpp::Element *  p0Element 
)
overridevirtual

Parse and create an event instance.

The implementation must call integrateAndAdd() to add the newly created event to the level which will own it.

Parameters
oCtxThe game context.
p0ElementThe element. Cannot be null.
Returns
The created event. Non owning. Is not null.
Exceptions
std::runtime_error.

Implements stmg::XmlEventParser.

◆ parseEventListenerGroupName()

int32_t stmg::XmlCumulCmpEventParser::parseEventListenerGroupName ( GameCtx oCtx,
const xmlpp::Element *  p0Element,
const std::string &  sAttr,
const std::string &  sListenerGroupName 
)
overridevirtual

Returns event type listener group value from name.

Usually listener group the name is the same as defined in the event class as an enum without the 'LISTENER_GROUP_' prefix.

Since also the Event base class has at least the LISTENER_GROUP_FINISHED enum and therefore the name 'FINISHED' defined, subclasses of this function should call XmlEventParser::parseEventListenerGroupName() after checking their own enums.

Parameters
oCtxThe game context.
p0ElementThe element containing the the attribute. Cannot be null.
sAttrThe attribute name containing the listener group name. Cannot be empty.
sListenerGroupNameThe listener group name. Cannot be empty.
Returns
The listener group value.
Exceptions
Ifthe listener group name is unknown.

Reimplemented from stmg::XmlEventParser.

◆ parseEventMsgName()

int32_t stmg::XmlCumulCmpEventParser::parseEventMsgName ( ConditionalCtx oCtx,
const xmlpp::Element *  p0Element,
const std::string &  sAttr,
const std::string &  sMsgName 
)
overridevirtual

Returns event type's msg value from msg name.

Usually the msg name is the same as defined in the event class as an enum without the 'MESSAGE_' prefix.

Subclasses of this function should call XmlEventParser::parseEventMsgName() after checking their own enums. The function will throw an error.

Parameters
oCtxThe game context.
p0ElementThe element containing the the attribute. Cannot be null.
sAttrThe attribute name containing the message name. Cannot be empty.
sMsgNameThe message name. Cannot be empty.
Returns
The message value.
Exceptions
Ifthe msg name is unknown.

Reimplemented from stmg::XmlEventParser.