Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ippExecutor.cpp

Go to the documentation of this file.
00001 // 
00002 // DISCLAIMER: 
00003 //  This software was produced by the National Institute of Standards 
00004 //  and Technology (NIST), an agency of the U.S. government, and by statute is 
00005 //  not subject to copyright in the United States.  Recipients of this 
00006 //  software assume all responsibility associated with its operation,
00007 //  modification,maintenance, and subsequent redistribution. 
00008 //
00009 //  See NIST Administration Manual 4.09.07 b and Appendix I. 
00010 //
00011 #include "stdafx.h"
00012 
00013 #include "ippdme/Executor/ippExecutor.h"
00014 
00015 #include "ippdme/Parser/ippCommandParser.h"
00016 
00017 #include "ippdme/Command/ippCommand.h"
00018 #include "ippdme/Response/ippCompleteResponse.h"
00019 #include "ippdme/Response/ippErrorResponse.h"
00020 
00021 #include "ippdme/assert.h"
00022 
00023 #ifdef _DEBUG
00024 #define new DEBUG_NEW
00025 #undef THIS_FILE
00026 static char THIS_FILE[] = __FILE__;
00027 #endif
00028 
00029 
00030 
00031 using namespace ipp;
00032 
00033 
00034 //=============================================================================
00035 ippExecutor::ippExecutor()
00036 //-----------------------------------------------------------------------------
00037  : _currentCommand(0)
00038 {
00039 
00040 }
00041 
00042 
00043 //=============================================================================
00044 void ippExecutor::resetExecutor()
00045 //-----------------------------------------------------------------------------
00046 {
00047 
00048 }
00049 
00050 //=============================================================================
00051 void ippExecutor::executeCommand(ippCommandPtr command)
00052 //-----------------------------------------------------------------------------
00053 {
00054   IPP_ASSERT_MSG(command->getCommandName() != AbortE ,
00055      "AbortE has a special treatment inside the simple server");
00056   
00057   _returningValues.reserve(25);
00058   _currentCommand = command;
00059 
00060   ippCommandNameType cnt = _currentCommand->getCommandName();
00061  
00062   switch(cnt)
00063   {
00064     // this code is equivalent to 
00065     //  case IsHome :  executeIsHomed(); break;
00066     // for all values defined in he COMMAND enumeration
00067 
00068 #define ENUM(value,function) case ipp::value: IPP_CONCAT(execute,value)(); break;
00069     COMMAND_ENUMERATION
00070 #undef ENUM
00071 
00072     default:
00073       generateErrorResponse(UnsupportedCommand," ippCommand is currently unsupported" );
00074       generateCompletedResponse();
00075       break;
00076   }
00077 }
00078 //=============================================================================
00079 void ippExecutor::AbortCurrentCommand()
00080 //-----------------------------------------------------------------------------
00081 {
00082    if (_currentCommand) { 
00083      generateErrorResponse(TransactionAborted,_currentCommand->getCommandString().c_str());
00084    } else {
00085      // no command to abort ...
00086    }
00087    generateCompletedResponse();
00088 }
00089 
00090 //=============================================================================
00091 ippResponseList ippExecutor::checkStatus()
00092 //-----------------------------------------------------------------------------
00093 {
00094 
00095         // Return and clear vector of responses
00096         ippResponseList rl;
00097         rl = _returningValues; //temp buff
00098         if (_returningValues.size() > 0) {
00099                 _returningValues.erase(_returningValues.begin(), _returningValues.end());
00100   }
00101         return rl;
00102 }
00103 
00107 
00108 //=============================================================================
00109 void ippExecutor::generateCompletedResponse()
00110 //-----------------------------------------------------------------------------
00111 {
00112   IPP_ASSERT(_currentCommand);
00113   unsigned int tag_num = _currentCommand->getTag().getTagNumber();
00114   ippResponsePtr x = new ippCompleteResponse(tag_num, _currentCommand->getTag().getTagType());
00115   _returningValues.push_back(x);
00116   _currentCommand = 0;
00117 }
00118 
00119 //=============================================================================
00120 void ippExecutor::generateErrorResponse(
00121   ippErrorNameType errorNum,
00122   const char * str
00123 )
00124 //-----------------------------------------------------------------------------
00125 {
00126   unsigned int tag_num = _currentCommand->getTag().getTagNumber();
00127   ippResponsePtr x = new ippErrorResponse(tag_num, CommandTag, errorNum, str);
00128   _returningValues.push_back(x);
00129 }
00130 
00131 
00132 //=============================================================================
00133 int  ippExecutor::DaemonCount() const
00134 //-----------------------------------------------------------------------------
00135 {
00136   return 0;
00137 }
00138 
00139 
00140 
00141 

Generated on Wed Nov 8 00:20:03 2006 for IPPDME by  doxygen 1.4.1