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

ippCommand.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/Command/ippCommand.h"
00014 #include "ippdme/misc/ippStringBuilder.h"
00015 
00016 #include "ippdme/assert.h"
00017 
00018 ippCommandPtr g;
00019 ippCommandPtr g1=g;
00020 
00021 ippCommand::ippCommand(
00022   unsigned int inTagNumber, 
00023   ippCommandNameType inCommandName
00024 )
00025   :  _tag(inTagNumber, inCommandName)
00026 {
00027   _commandName = inCommandName;
00028 }
00029 
00030 
00031 ippCommand::ippCommand(
00032   unsigned int inTagNumber,
00033   tagIdType inTagType,
00034   ippCommandNameType inCommandName
00035 )
00036   : _tag(inTagNumber, inTagType)
00037 {
00038   _commandName = inCommandName;      
00039   
00040 }
00041 
00042 ippCommand::~ippCommand()
00043 {
00044 
00045 }
00046 
00047 
00048 
00049 const char * getCommandNameString(ippCommandNameType key)
00050 { 
00051   switch(key)
00052   {
00053 #define ENUM(a,b) case ipp::a: return b;
00054     COMMAND_ENUMERATION
00055 #undef  ENUM
00056   };
00057   return "bug";
00058 }
00059 
00060 
00061 
00062 
00063 /*
00064  ippCommand::printLikeGet
00065 
00066 This must always be the last function that prints into the buffer
00067 because this adds the ending. If the command being printed has any
00068 arguments, there will be a comma at position k-2 when this function
00069 finishes printing arguments, and that comma is removed. The
00070 OnMoveReportECommand is not required to have any arguments.
00071 
00072 Called By:
00073   GetCommand::getCommandString
00074   OnMoveReportECommand::getCommandString
00075   OnPtMeasReportCommand::getCommandString
00076   OnScanReportCommand::getCommandString
00077 */
00078 void ippCommand::printLikeGet(
00079   ippStringBuilder& builder,
00080   bool R, 
00081   bool X, bool Y, bool Z,
00082   bool A, bool B, bool C
00083 ) const
00084 {
00085   if (R) builder.AppendFunc("R");
00086   if (X) builder.AppendFunc("X");
00087   if (Y) builder.AppendFunc("Y");
00088   if (Z) builder.AppendFunc("Z");
00089   if (A) builder.AppendFunc("Tool.A");
00090   if (B) builder.AppendFunc("Tool.B");
00091   if (C) builder.AppendFunc("Tool.C");
00092 }
00093 
00094 
00095 
00096 /* getCommandString *****************************************************
00097 
00098 This prints the command string into the "answer" array first, then
00099 copies into the buffer if the buffer is large enough.
00100 
00101 If the _commandName is not recognized or if the buffer is too small,
00102 this returns NULL. Otherwise, it returns buffer.
00103 
00104 The definitions of getCommandString for the various classes follow,
00105 arranged alphabetically by class. None of the getCommandStringT
00106 methods check that the "answer" array is large enough to hold the
00107 command. This check could be added, but adding it would be
00108 tedious. The answer array holds IPPSIZE (65536) characters.
00109 
00110 */
00111 std::string ippCommand::getCommandString() const
00112 {
00113   
00114   switch(_commandName)
00115   {
00116     case AbortE:
00117     case ClearAllErrors:
00118     case DisableUser:
00119     case EnableUser:
00120     case EndSession:
00121     case EnumTools:
00122     case GetCoordSystem:
00123     case GetDMEVersion:
00124     case GetErrStatusE:
00125     case GetMachineClass:
00126     case GetXtdErrStatus:
00127     case Home:
00128     case IsHomed:
00129     case IsUserEnabled:
00130     case ReQualify:
00131     case StartSession:
00132     case StopAllDaemons:
00133     case EnumCoordSystems: {
00134       ippStringBuilder builder(_tag);
00135       builder.StartFunc(getCommandNameString(_commandName));
00136       builder.EndFunc();
00137       return builder.ToString();
00138       break;       
00139    }
00140    default: {
00141     IPP_ASSERT_FAIL("Unsupported case :");
00142     return "ERROR";
00143    }
00144   }
00145 }
00146 

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