Address.h

Go to the documentation of this file.
00001 // -*- mode: C++ -*- 
00002 //
00003 // Copyright (C) 2006 Christian Holm Christensen <cholm@nbi.dk>
00004 //
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public License
00007 // as published by the Free Software Foundation; either version 2.1
00008 // of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free
00017 // Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018 // 02111-1307 USA
00019 //
00025 #ifndef RCUCONF_ADDRESS_H
00026 #define RCUCONF_ADDRESS_H
00027 #ifndef RCUCONF_TABLE_H
00028 # include <rcuconf/Table.h>
00029 #endif
00030 #ifndef __LIST__
00031 # include <list>
00032 #endif
00033 
00034 namespace RcuDb 
00035 {
00036   class Row;
00037   class Sql;
00038 }
00039 
00040 
00041 namespace RcuConf 
00042 {
00043   // Forward declarations 
00044   class Value;
00045 
00051   class Address : public Table
00052   {
00053   public:
00058     Address(int board, int chip=0, int channel=0) 
00059       : fAddress(((board   & 0x1F) << 7) +
00060                  ((chip    & 0x07) << 4) + 
00061                  ((channel & 0x0F)))
00062     {}
00064     virtual ~Address() { }
00065 
00067     typedef std::list<Address*> List;
00068 
00070     virtual void Print() const;
00073     virtual bool Insert(RcuDb::Server& s);
00076     static  bool Create(RcuDb::Server& s);
00079     static  bool Drop(RcuDb::Server& s);
00085     static  bool Select(List& l, RcuDb::Server& s, const RcuDb::Sql& cond);
00091     static  bool Select(List& l, RcuDb::Server& s, const Value& v);
00092 
00094     int Board() const { return (fAddress >> 7) & 0x1f; }
00096     int Chip() const { return (fAddress >> 4) & 0x7; }
00098     int Channel() const { return (fAddress & 0xf); }
00100     int RawValue() const { return fAddress; }
00101   protected:
00104     Address(RcuDb::Row& row);
00106     int fAddress;
00107   };
00108 }
00109 
00110 #endif
00111 //
00112 // EOF
00113 //
00114 
00115   
Top of page Last update Fri Apr 27 01:54:15 2007
Copyright © 2004 Christian Holm Created by DoxyGen 1.3.5