Jopnal Engine  alpha 0.4
Simple Component Based 2D/3D Game Engine
Public Types | Public Member Functions | List of all members
jop::Message Class Reference

#include <Message.hpp>

Public Types

enum  Filter : unsigned short {
  Subsystem = 1, SharedScene = 1 << 1, Scene = 1 << 2, Object = 1 << 3,
  Component = 1 << 4, Global = 0xFFFF
}
 
enum  Result { Result::Continue, Result::Escape }
 

Public Member Functions

 Message (const std::string &message)
 Constructor. More...
 
template<typename T >
Messagepush (const T &arg)
 Push an argument value. More...
 
Messagepush (const std::string &str)
 Push a string argument. More...
 
Messagepush (const char *str)
 Push a string argument. More...
 
MessagepushPointer (const void *ptrArg)
 Push a pointer argument. More...
 
template<typename T >
MessagepushReference (const T &ref)
 Push a reference argument. More...
 
const std::string & getString () const
 Get a string with the command and arguments. More...
 
bool passFilter (const unsigned short filter) const
 Check if the given bit field should pass the filter. More...
 
bool passFilter (const std::string &id) const
 Check if the given id should pass the filter. More...
 
bool passFilter (const std::unordered_set< std::string > &tags) const
 Check if the given tags should pass the filter. More...
 
MessagesetFilter (const std::string &filter)
 Set the filter. More...
 
 operator bool () const
 Check the internal command/argument buffer. More...
 

Detailed Description

Definition at line 38 of file Message.hpp.

Member Enumeration Documentation

enum jop::Message::Filter : unsigned short

System filtering bits

Enumerator
Subsystem 
SharedScene 
Scene 
Object 
Component 
Global 

Definition at line 48 of file Message.hpp.

enum jop::Message::Result
strong

Message result

Enumerator
Continue 

Continue to process the message.

Escape 

Return from sendMessage.

Definition at line 60 of file Message.hpp.

Constructor & Destructor Documentation

jop::Message::Message ( const std::string &  message)

Constructor.

Parameters
messageThe message. May include just a filter or be empty, in which case you must push the command & arguments separately

Member Function Documentation

const std::string& jop::Message::getString ( ) const

Get a string with the command and arguments.

Returns
A new string with the internal buffer's contents
jop::Message::operator bool ( ) const

Check the internal command/argument buffer.

Returns
True if the buffer has at least a command
bool jop::Message::passFilter ( const unsigned short  filter) const

Check if the given bit field should pass the filter.

Parameters
filterThe bits to check. Only one match is required for a pass
Returns
True if the filter was passed
bool jop::Message::passFilter ( const std::string &  id) const

Check if the given id should pass the filter.

Parameters
idThe id to check
Returns
True if the filter was passed
bool jop::Message::passFilter ( const std::unordered_set< std::string > &  tags) const

Check if the given tags should pass the filter.

Parameters
tagsThe tags to check
Returns
True if the filter was passed
template<typename T >
Message& jop::Message::push ( const T &  arg)

Push an argument value.

Parameters
argThe argument to push
Returns
Reference to self
Message& jop::Message::push ( const std::string &  str)

Push a string argument.

This can be used to push the command, if the message passed to the constructor didn't have it.

Parameters
strThe argument to push
Returns
Reference to self
Message& jop::Message::push ( const char *  str)

Push a string argument.

This can be used to push the command, if the message passed to the constructor didn't have it.

Parameters
strThe argument to push
Returns
Reference to self
Message& jop::Message::pushPointer ( const void *  ptrArg)

Push a pointer argument.

The pointer will be converted into a hex string and then interpreted by the command handler to recreate the pointer.

Parameters
ptrArgThe pointer to push
Returns
Reference to self
template<typename T >
Message& jop::Message::pushReference ( const T &  ref)

Push a reference argument.

Essentially does the same as pushPointer().

Parameters
refThe reference to push
Returns
Reference to self
Message& jop::Message::setFilter ( const std::string &  filter)

Set the filter.

Parameters
filterA filter field in the correct form
Returns
Reference to self

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