#include "DConsoleContext.h" #include "Providers/DMySQLDataProvider.h" #include namespace ccdb { // Global static pointer used to ensure a single instance of the class. DConsoleContext* DConsoleContext::mInstance = NULL; /** This function is called to create an instance of the class. Calling the constructor publicly is not allowed. The constructor is private and is only called by this Instance function. */ DConsoleContext* DConsoleContext::Instance() { if (!mInstance) // Only allow one instance of class to be generated. mInstance = new DConsoleContext(); return mInstance; } DConsoleUtilBase * DConsoleContext::FindUtil( string command ) { //just search it map::iterator utilIt = mUtils.find(command); if(utilIt == mUtils.end()) { //not found, return NULL return NULL; } return utilIt->second; } int DConsoleContext::ProcessInteractive( int argc, char* argv[], int startArgc /*= 2*/ ) { //TODO: Implement method return -1; } DConsole * DConsoleContext::GetConsole() const { return mConsole; } DConsoleContext::DConsoleContext() { mConsole = new DConsole(); mConsole->SetUseColors(true); mProvider = new DMySQLDataProvider(); } DConsoleContext::~DConsoleContext( void ) { if(mConsole) delete mConsole; } const map& DConsoleContext::GetUtils() { return mUtils; } void DConsoleContext::RegisterConsoleUtil( string command, DConsoleUtilBase *util ) { assert(util != NULL); mUtils[command] = util; } }