pin.h

Go to the documentation of this file.
00001 ///
00002 /// \file       pin.h
00003 ///             class for device PIN notation
00004 ///
00005 
00006 /*
00007     Copyright (C) 2007-2012, Net Direct Inc. (http://www.netdirect.ca/)
00008 
00009     This program is free software; you can redistribute it and/or modify
00010     it under the terms of the GNU General Public License as published by
00011     the Free Software Foundation; either version 2 of the License, or
00012     (at your option) any later version.
00013 
00014     This program is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00017 
00018     See the GNU General Public License in the COPYING file at the
00019     root directory of this project for more details.
00020 */
00021 
00022 #ifndef __BARRY_PIN_H__
00023 #define __BARRY_PIN_H__
00024 
00025 #include "dll.h"
00026 #include <stdint.h>
00027 #include <string>
00028 
00029 namespace Barry {
00030 
00031 class BXEXPORT Pin
00032 {
00033         uint32_t pin;
00034 
00035 public:
00036         Pin(uint32_t pin__ = 0) : pin(pin__) {}
00037 
00038         bool Valid() const { return pin != 0; }
00039         void Clear() { pin = 0; }
00040         std::string Str() const;
00041         uint32_t Value() const { return pin; }
00042 
00043         Pin& operator=(uint32_t p) { pin = p; return *this; }
00044 
00045         bool operator==(uint32_t rhs) const { return pin == rhs; }
00046         bool operator==(const Pin &rhs) const { return pin == rhs.pin; }
00047 
00048         bool operator!=(uint32_t rhs) const { return pin != rhs; }
00049         bool operator!=(const Pin &rhs) const { return pin != rhs.pin; }
00050 };
00051 
00052 // no ostream operator, since we want to encourage users to call str()...
00053 // but istream may be useful
00054 BXEXPORT std::istream& operator>>(std::istream &is, Pin &pin);
00055 
00056 } // namespace Barry
00057 
00058 #endif
00059