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

ippOnScanReportBuilder.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 #include "ippdme/misc/ippOnScanReportBuilder.h"
00013 
00014 #include "ippdme/assert.h"
00015 
00016 
00017 int ippOnScanReportBuilder::_max_number_of_values  = 1000;
00018 
00019 ippOnScanReportBuilder::ippOnScanReportBuilder(
00020   ippOnScanReportCommandConstPtr report
00021 )
00022 : _OnScanReportCmd(report)
00023 , _baseIndex(-1)
00024 {
00025   _values.reserve(_max_number_of_values);
00026   
00027   // 65535 /20 
00028 }
00029 
00030 void ippOnScanReportBuilder::setValue(
00031   ippOnScanReportCommand::Key key,
00032   double value
00033 )
00034 {
00035   IPP_ASSERT_MSG(_baseIndex!=-1,"Start hasn't been called");
00036   int index = _OnScanReportCmd->getIndexOf(key) ;
00037   if (index >=0 ) { // if the value has to be reported
00038     _values[index+ _baseIndex] = value;
00039   }
00040 }
00041 void ippOnScanReportBuilder::setValues(
00042   ippOnScanReportCommand::Key key,
00043   double vI,
00044   double vJ,
00045   double vK
00046 )
00047 {
00048   IPP_ASSERT_MSG(_baseIndex!=-1,"Start hasn't been called");
00049   int index = _OnScanReportCmd->getIndexOf(key) ;
00050   if (index >=0 ) { 
00051     _values[index+_baseIndex+0] = vI;
00052     _values[index+_baseIndex+1] = vJ;
00053     _values[index+_baseIndex+2] = vK;
00054   }
00055 }
00056 
00057 
00058 void ippOnScanReportBuilder::StartPoint()
00059 {
00060   IPP_ASSERT_MSG(_baseIndex==-1,"Commit hasn't been called");
00061   _baseIndex = _values.size();
00062   _values.resize(_baseIndex+_OnScanReportCmd->getNumberOfReportedValues());
00063 
00064 }
00065 void ippOnScanReportBuilder::Commit()
00066 {
00067   IPP_ASSERT_MSG(_baseIndex!=-1,"Start hasn't been called");
00068   _baseIndex = -1;
00069 }
00070 
00071 bool ippOnScanReportBuilder::IsNearlyFull() const 
00072 {
00073   return _values.size()>_max_number_of_values;
00074 }
00075 
00076 bool ippOnScanReportBuilder::IsEmpty() const
00077 {
00078   IPP_ASSERT_MSG(_baseIndex==-1,"Commit hasn't been called");
00079   return _values.size() ==0;
00080 }
00081 
00082 
00083 ippScanResponsePtr ippOnScanReportBuilder::FlushAndGetResponse(unsigned tagNum)
00084 {
00085   //xx int tagNum = _OnScanReportCmd->getTag().getTagNumber();
00086   ippScanResponsePtr x = new ippScanResponse(tagNum, _values.size(), &_values[0]);
00087   _values.resize(0);
00088   return x;  
00089 }

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