Cppgram  1.0.0
Easy and modern C++14 Telegram Bot API wrapper
Public Member Functions | Private Member Functions | List of all members
CommandHandler< T > Class Template Reference

Handle bot commands. More...

#include <command_handler.hpp>

Public Member Functions

 CommandHandler ()
 Empty object.
 
 CommandHandler (T *bot)
 Construct this object with empty commands. More...
 
 CommandHandler (T *bot, const CommandHandler &c)
 Construct this object. More...
 
 CommandHandler (const CommandHandler &c)
 Copy constructor.
 
CommandHandleroperator= (const CommandHandler &c)
 Assigment constructor. More...
 
CommandHandleroperator= (CommandHandler &&c)
 Move assigment operator. More...
 
void addCommand (commands::Command< T > *new_command)
 Add a bot command. More...
 
void setCommands (const CommandHandler &c)
 copy commands of another object of type CommandHandler More...
 

Private Member Functions

void init (T *bot)
 Check if this object has an owner and set it to bot if not. More...
 

Detailed Description

template<class T>
class cppgram::CommandHandler< T >

Handle bot commands.

Store commands and check if an update trigger a command.

Constructor & Destructor Documentation

◆ CommandHandler() [1/2]

CommandHandler ( T *  bot)

Construct this object with empty commands.

Parameters
botPointer to the bot owner.

◆ CommandHandler() [2/2]

CommandHandler ( T *  bot,
const CommandHandler< T > &  c 
)

Construct this object.

Parameters
botOwner of this object.
cCommandHandler that owns the commands.

Member Function Documentation

◆ addCommand()

void addCommand ( commands::Command< T > *  new_command)

Add a bot command.

Parameters
new_commandPointer to the command to add.

◆ init()

void init ( T *  bot)
private

Check if this object has an owner and set it to bot if not.

Parameters
botPointer to the bot owner of this object.

◆ operator=() [1/2]

CommandHandler< T > & operator= ( const CommandHandler< T > &  c)

Assigment constructor.

A CommandHandler will be initialized with the same commands as the rvalue, but the returned object will not have any owner as two CommandHandler objects cannot share the same owner.

Parameters
crvalue.
Returns
CommandHandler object with the same commands as the rvalue.

◆ operator=() [2/2]

CommandHandler< T > & operator= ( CommandHandler< T > &&  c)

Move assigment operator.

Assign the exact owner and all the commands to an other object using the assignation.

Parameters
crvalue.

◆ setCommands()

void setCommands ( const CommandHandler< T > &  c)

copy commands of another object of type CommandHandler

Parameters
cObjects that owns the command to copy.

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