Yingdi Yu | ede8eaf | 2013-10-14 14:07:03 -0700 | [diff] [blame^] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2013, Regents of the University of California |
| 4 | * Yingdi Yu |
| 5 | * |
| 6 | * BSD license, See the LICENSE file for more information |
| 7 | * |
| 8 | * Author: Yingdi Yu <yingdi@cs.ucla.edu> |
| 9 | */ |
| 10 | |
| 11 | #ifndef LINKNDN_CONTACT_STORAGE_H |
| 12 | #define LINKNDN_CONTACT_STORAGE_H |
| 13 | |
| 14 | #include <sqlite3.h> |
| 15 | #include "trusted-contact.h" |
| 16 | #include "contact-item.h" |
| 17 | |
| 18 | class ContactStorage |
| 19 | { |
| 20 | public: |
| 21 | ContactStorage(); |
| 22 | |
| 23 | ~ContactStorage() {} |
| 24 | |
| 25 | void |
| 26 | addTrustedContact(const TrustedContact& trustedContact); |
| 27 | |
| 28 | void |
| 29 | addNormalContact(const ContactItem& contactItem); |
| 30 | |
| 31 | std::vector<ndn::Ptr<TrustedContact> > |
| 32 | getAllTrustedContacts() const; |
| 33 | |
| 34 | std::vector<ndn::Ptr<ContactItem> > |
| 35 | getAllNormalContacts() const; |
| 36 | |
| 37 | private: |
| 38 | inline bool |
| 39 | doesTrustedContactExist(const ndn::Name& name) |
| 40 | { return doesContactExist(name, false); } |
| 41 | |
| 42 | inline bool |
| 43 | doesNormalContactExist(const ndn::Name& name) |
| 44 | { return doesContactExist(name, true); } |
| 45 | |
| 46 | bool |
| 47 | doesContactExist(const ndn::Name& name, bool normal); |
| 48 | |
| 49 | private: |
| 50 | sqlite3 *m_db; |
| 51 | }; |
| 52 | |
| 53 | #endif |