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-2010, 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 
00040         void clear() { pin = 0; }
00041         std::string str() const;
00042         uint32_t value() const { return pin; }
00043 
00044         Pin& operator=(uint32_t p) { pin = p; return *this; }
00045 
00046         bool operator==(uint32_t rhs) const { return pin == rhs; }
00047         bool operator==(const Pin &rhs) const { return pin == rhs.pin; }
00048 
00049         bool operator!=(uint32_t rhs) const { return pin != rhs; }
00050         bool operator!=(const Pin &rhs) const { return pin != rhs.pin; }
00051 };
00052 
00053 // no ostream operator, since we want to encourage users to call str()...
00054 // but istream may be useful
00055 BXEXPORT std::istream& operator>>(std::istream &is, Pin &pin);
00056 
00057 } // namespace Barry
00058 
00059 #endif
00060 
Generated by  doxygen 1.6.2-20100208