Always include the boost-package. Otherwise it won't get searched on a second run.
[amule.git] / src / kademlia / utils / KadUDPKey.h
blobf086b30f4bedc55632d8cd662ae5973fbb8ff58b
1 // -*- C++ -*-
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2008-2011 Dévai Tamás ( gonosztopi@amule.org )
5 // Copyright (c) 2008-2011 aMule Team ( admin@amule.org / http://www.amule.org )
6 // Copyright (c) 2002-2011 Merkur ( devs@emule-project.net / http://www.emule-project.net )
7 //
8 // Any parts of this program derived from the xMule, lMule or eMule project,
9 // or contributed by third-party developers are copyrighted by their
10 // respective authors.
12 // This program is free software; you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation; either version 2 of the License, or
15 // (at your option) any later version.
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #ifndef KADEMLIA_UTILS_KADUDPKEY_H
28 #define KADEMLIA_UTILS_KADUDPKEY_H
30 #include "../../SafeFile.h"
32 namespace Kademlia
35 class CKadUDPKey
37 public:
38 CKadUDPKey(uint32_t WXUNUSED_UNLESS_DEBUG(zero) = 0) { wxASSERT(zero == 0); m_key = m_ip = 0; }
39 CKadUDPKey(uint32_t key, uint32_t ip) throw() { m_key = key; m_ip = ip; }
40 CKadUDPKey(CFileDataIO& file) { ReadFromFile(file); }
41 CKadUDPKey& operator=(const CKadUDPKey& k1) throw() { m_key = k1.m_key; m_ip = k1.m_ip; return *this; }
42 CKadUDPKey& operator=(const uint32_t WXUNUSED_UNLESS_DEBUG(zero)) { wxASSERT(zero == 0); m_key = m_ip = 0; return *this; }
43 friend bool operator==(const CKadUDPKey& k1, const CKadUDPKey& k2) throw() { return k1.GetKeyValue(k1.m_ip) == k2.GetKeyValue(k2.m_ip);}
45 uint32_t GetKeyValue(uint32_t myIP) const throw() { return (myIP == m_ip) ? m_key : 0; }
46 bool IsEmpty() const throw() { return (m_key == 0) || (m_ip == 0); }
47 void StoreToFile(CFileDataIO& file) const { file.WriteUInt32(m_key); file.WriteUInt32(m_ip); }
48 void ReadFromFile(CFileDataIO& file) { m_key = file.ReadUInt32(); m_ip = file.ReadUInt32(); }
50 private:
51 uint32_t m_key;
52 uint32_t m_ip;
55 } // namespace Kademlia
57 #endif /* KADEMLIA_UTILS_KADUDPKEY_H */