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

ippOnScanReportCommand.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/ippOnScanReportCommand.h"
00014 #include "ippdme/misc/ippStringBuilder.h"
00015 #include "ippdme/ippProp.h"
00016 #include "ippdme/assert.h"
00017 
00018 // Note : the ippOnScanReportCommand should ultimately remember in 
00019 //        which order the various parameter has been passed to it
00020 //        as this will impact on the output returned by the server containing
00021 //        the scan result, 
00022 //        At this time our implementation doesn't take this into account... 
00023 //        this constraint doen't not apply to ippOnPtMeasReportCommand
00024 //        as the output produced by the server will use a richer text that
00025 //        will allow the client to find out what reported values are.
00026 //        (Etienne)
00027 //
00028 ippOnScanReportCommand::ippOnScanReportCommand(
00029     unsigned int tgNum
00030 
00031 )
00032  : ippCommand(tgNum, CommandTag, OnScanReport)
00033 {
00034   reset();
00035 }
00036 
00037 void ippOnScanReportCommand::reset()
00038 {
00039   // -1 mean not used 
00040   _usedKey[ippOnScanReportCommand::ER]   = -1; 
00041   _usedKey[ippOnScanReportCommand::Q]    = -1;
00042   _usedKey[ippOnScanReportCommand::R]   = -1;
00043   _usedKey[ippOnScanReportCommand::X]   = -1;
00044   _usedKey[ippOnScanReportCommand::Y]   = -1;
00045   _usedKey[ippOnScanReportCommand::Z]   = -1;
00046   _usedKey[ippOnScanReportCommand::IJK] = -1;
00047   _usedKey[ippOnScanReportCommand::IJKAct] = -1;
00048   _usedKey[ippOnScanReportCommand::ToolA] = -1;
00049   _usedKey[ippOnScanReportCommand::ToolB] = -1;
00050   _usedKey[ippOnScanReportCommand::ToolC] = -1;
00051 
00052   _lastIndex = 0;
00053 }
00054 
00055 void ippOnScanReportCommand::append(Key key)
00056 {
00057   // verify that the key is supported
00058   IPP_ASSERT(_usedKey.find(key) != _usedKey.end());
00059 
00060   // verify that the tag hasn't been appended yet (-1)
00061   IPP_ASSERT(_usedKey[key]==-1);
00062 
00063   _orderedKey.push_back(key);
00064   
00065   // mark the tag as being used
00066   _usedKey[key] =_lastIndex ++; // index 
00067   if (key == IJK) { 
00068     _lastIndex +=2 ; // add 2 more
00069   }
00070 
00071 }
00072 
00073 void ippOnScanReportCommand::setDefault()
00074 {
00075   reset();
00076   append(ippOnScanReportCommand::X);
00077   append(ippOnScanReportCommand::Y);
00078   append(ippOnScanReportCommand::Z);
00079   append(ippOnScanReportCommand::Q);
00080 }
00081 
00082 int ippOnScanReportCommand::getIndexOf(Key key) const
00083 {
00084   // verify that the key is supported
00085   IPP_ASSERT(_usedKey.find(key) != _usedKey.end());
00086   return _usedKey.find(key)->second ;
00087 }
00088 
00089 int ippOnScanReportCommand::getNumberOfReportedValues() const
00090 {
00091   int n = _orderedKey.size();
00092   if ( getHasIJK() ) { 
00093      n+=2 ; // IJK reports also J and K 
00094   }
00095   IPP_ASSERT(_lastIndex == n);
00096   return n;
00097 }
00098 
00099 bool ippOnScanReportCommand::getHasER() const
00100 {
00101   return getIndexOf(ER) != -1;
00102 }
00103 
00104 bool ippOnScanReportCommand::getHasIJK() const
00105 {
00106   return getIndexOf(IJK) != -1;
00107 }
00108 
00109 bool ippOnScanReportCommand::getHasQ() const
00110 {
00111   return getIndexOf(Q) != -1;
00112 }
00113 
00114 bool ippOnScanReportCommand::getHasR() const
00115 {
00116   return getIndexOf(R) != -1;
00117 }
00118 
00119 bool ippOnScanReportCommand::getHasX() const
00120 {
00121   return getIndexOf(X) != -1;
00122 }
00123 
00124 bool ippOnScanReportCommand::getHasY() const
00125 {
00126   return getIndexOf(Y) != -1;
00127 }
00128 
00129 bool ippOnScanReportCommand::getHasZ() const
00130 {
00131   return getIndexOf(Z) != -1;
00132 }
00133 
00134 bool ippOnScanReportCommand::getHasToolA() const
00135 {
00136   return getIndexOf(ToolA) != -1;
00137 }
00138 
00139 bool ippOnScanReportCommand::getHasToolB() const
00140 {
00141   return getIndexOf(ToolB) != -1;
00142 }
00143 
00144 bool ippOnScanReportCommand::getHasToolC() const
00145 {
00146   return getIndexOf(ToolC) != -1;
00147 }
00148 
00149 bool ippOnScanReportCommand::getHasIJKAct() const
00150 {
00151   return getIndexOf(IJKAct) != -1;
00152 }
00153 
00154 std::string ippOnScanReportCommand::getCommandString() const
00155 {
00156   ippStringBuilder builder(_tag);
00157   builder.StartFunc("OnScanReport");
00158 
00159   for (int i=0;i<_orderedKey.size();i++) {
00160 
00161     ippOtherKeyType key = (ippOtherKeyType)_orderedKey[i];
00162 
00163     if ( key == _A || key == _B || key == _C) { 
00164        // special cases for Tool.A() etc...
00165        ippProp prop(Tool,key);
00166        builder.AppendFunc(prop.toString().c_str());
00167    } else {
00168       builder.AppendFunc(getKeyString(key));
00169     }
00170   }
00171 
00172 
00173   builder.EndFunc();
00174   return builder.ToString();
00175  
00176 }
00177 
00178 
00179 ippOnScanReportCommand::~ippOnScanReportCommand()
00180 {
00181   _orderedKey.clear();
00182   _usedKey.clear();
00183 }

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