home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 Mobile / Chip_Mobile_2001.iso / palm / business / printcar / printcar.exe / src / IrDA / IrIasParameters.h < prev    next >
C/C++ Source or Header  |  2000-06-05  |  3KB  |  113 lines

  1. //
  2. //  $Id: IrIasParameters.h,v 1.2 2000/06/04 23:23:41 sergey Exp $
  3. //
  4.  
  5. #ifndef _IrIasParameters_h_
  6. #define _IrIasParameters_h_
  7.  
  8.  
  9. namespace IrDA
  10. {
  11.     //==========================================================================
  12.     // IasParameter class
  13.     //==========================================================================
  14.  
  15.     class IasParameter
  16.     {
  17.     public:
  18.         IasParameter(): _identifier(0), _length(0), _value(NULL) {}
  19.         virtual ~IasParameter() {}
  20.  
  21.         // IasParameter(const IasParameter&);
  22.         // IasParameter& operator =(const IasParameter&);
  23.  
  24.     // operations
  25.  
  26.         void initFrom(const Byte* stream);
  27.  
  28.     // attributes
  29.  
  30.         virtual bool checkType() const = 0;
  31.  
  32.         int size() const { return sizeof(_identifier)+sizeof(_length)+_length; }
  33.  
  34.     protected:
  35.         // Only service type and port type are currently supported.
  36.         enum ParameterType
  37.         {
  38.             SeviceTypeParameter     = 0x0,
  39.             PortTypeParameter       = 0x1
  40.         };
  41.  
  42.         ParameterType type() const { return (ParameterType)_identifier; }
  43.         const Byte* value() const { return _value; }
  44.  
  45.     // data members
  46.     private:
  47.         Byte _identifier;
  48.         Byte _length;
  49.         const Byte* _value;
  50.     };
  51.  
  52.     //==========================================================================
  53.     // IasServiceTypeParameter class
  54.     //==========================================================================
  55.  
  56.     class IasServiceTypeParameter: public IasParameter
  57.     {
  58.     public:
  59.  
  60.     // attribute
  61.  
  62.         virtual bool checkType() const { return type() == SeviceTypeParameter; }
  63.  
  64.         bool is3WireRaw() const     { return *value() & 0x01; }
  65.         bool is3Wire() const        { return *value() & 0x02; }
  66.         bool is9Wire() const        { return *value() & 0x04; }
  67.         bool isCentronics() const   { return *value() & 0x08; }
  68.     };
  69.  
  70.  
  71.     //==========================================================================
  72.     // IasPortTypeParameter class
  73.     //==========================================================================
  74.  
  75.     class IasPortTypeParameter: public IasParameter
  76.     {
  77.     public:
  78.  
  79.     // attributes
  80.  
  81.         virtual bool checkType() const { return type() == PortTypeParameter; }
  82.  
  83.         bool isSerial() const       { return *value() & 0x01; }
  84.         bool isParallel() const     { return *value() & 0x02; }
  85.     };
  86.  
  87.  
  88.     //==========================================================================
  89.     // IasParameterList class
  90.     //==========================================================================
  91.  
  92.     class IasParameterList
  93.     {
  94.     public:
  95.         IasParameterList(const Byte* stream, int size);
  96.  
  97.         // IasParameterList(const IasParameterList&);
  98.         // IasParameterList& operator =(IasParameterList&);
  99.  
  100.     // operations
  101.  
  102.         bool getParameter(IasParameter& parameter) const;
  103.  
  104.     // data members
  105.     private:
  106.         const Byte* _stream;
  107.         int _size;
  108.     };
  109. }
  110. // namespace IrDA
  111.  
  112. #endif  // _IrIasParameters_h_
  113.