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

ippTag.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/ippTag.h"
00014 #include "ippdme/assert.h"
00015 
00016 ippTag::ippTag(
00017   unsigned int inTagNumber, 
00018   ippCommandNameType id
00019 )
00020 {
00021   _tagNumber = inTagNumber;
00022   setTagType(id);
00023 }
00024 
00025 ippTag::ippTag(unsigned int inTagNumber, tagIdType inTagType)
00026 {
00027   _tagNumber = inTagNumber;
00028   _tagType = inTagType;
00029 }
00030 
00031 void ippTag::setTagNumber(unsigned int inTagNumber)
00032 { 
00033   _tagNumber = inTagNumber;
00034 }
00035 
00036 void ippTag::setTagType(tagIdType inTagType)
00037 { 
00038   _tagType = inTagType; 
00039 }
00040 
00041 unsigned int ippTag::getTagNumber() const 
00042 {
00043   return _tagNumber; 
00044 }
00045 
00046 tagIdType ippTag::getTagType() const 
00047 { 
00048   return _tagType; 
00049 }
00050 
00051 inline ippTag::~ippTag()
00052 {
00053 }
00054 
00055 void ippTag::setTagType(ippCommandNameType commandName)
00056 {
00057   switch(commandName)
00058     { 
00059     case AbortE:
00060       _tagType = EventTag;
00061       break;
00062     case GetPropE:
00063       _tagType = EventTag;
00064       break;
00065     case OnMoveReportE:
00066       _tagType = EventTag;
00067       break;
00068     case GetErrStatusE:
00069       _tagType = EventTag;
00070       break;
00071     default:
00072       _tagType = CommandTag;
00073     }
00074 }
00075 
00076 /* ippTag::getTagString ****************************************************
00077 
00078 For command tags, this allows tags in the range [1, 99999]. For
00079 event tags, this allows [E0000, E9999]. These are the ranges provided
00080 in the spec, pages 35 and 36. If a tag is out of range, buffer is
00081 set to NULL.
00082 
00083 The buffer must be at least TAGSTRINGSIZE (6) characters long.
00084 
00085 Since the _tagNumber is an unsigned int, it does not need to be tested
00086 for being positive. 
00087 
00088 */
00089 
00090 std::string ippTag::getTagString() const
00091 {
00092   static char buffer[10];
00093   buffer[0]=0;
00094 
00095   if (_tagType == CommandTag) {
00096     IPP_ASSERT(_tagNumber <100000);
00097     if ((_tagNumber > 0) && (_tagNumber < 100000)) {
00098       sprintf(buffer, "%05d", _tagNumber);
00099     }  else {
00100       IPP_ASSERT_FAIL(" Command cannot be null");
00101     }
00102 
00103   } else if (_tagType == EventTag) {
00104       IPP_ASSERT(_tagNumber <10000);
00105       if (_tagNumber < 10000) {
00106         sprintf(buffer, "E%04d", _tagNumber);
00107       }
00108 
00109   }  
00110   return buffer;
00111 }

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