Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Elmo-Terminal by
Commands/CmdFactory.cpp
- Committer:
- WGorniak
- Date:
- 2015-10-01
- Revision:
- 2:8d8295a51f68
File content as of revision 2:8d8295a51f68:
#include "mbed.h" #include "Serial.h" #include "CmdFactory.h" #include "CmdList.h" CmdFactory::CmdFactory(Settings* settings, Serial *serial) : settings_(settings), serial_(serial) { } CmdFactory::~CmdFactory() { } template <> Cmd* CmdFactory::create<int>(const std::string& cmd) const { return NULL; } template <typename cmds> Cmd* CmdFactory::create(const std::string& cmd) const { typedef typename cmds::t T; if (0 == cmd.compare(T::cmd())) { return new T(settings_); } return create<typename cmds::tn>(cmd); // tail call recursion - optimized out (-O2) } Cmd* CmdFactory::createCmd(std::string cmd) const { Cmd* command = create<CmdList>(cmd); if (!command) { serial_->printf("No such command %s\r\n", cmd.c_str()); } return command; }