Yingdi Yu | 5ff6210 | 2013-10-13 17:24:50 -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_PROFILE_H |
| 12 | #define LINKNDN_PROFILE_H |
| 13 | |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 14 | #include <ndn-cpp-dev/name.hpp> |
| 15 | #include <ndn-cpp-dev/security/identity-certificate.hpp> |
Yingdi Yu | 5ff6210 | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 16 | #include <map> |
| 17 | #include <string> |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 18 | #include "profile.pb.h" |
Yingdi Yu | 5ff6210 | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 19 | |
| 20 | class Profile |
| 21 | { |
| 22 | public: |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 23 | typedef std::map<std::string, std::string>::iterator iterator; |
| 24 | typedef std::map<std::string, std::string>::const_iterator const_iterator; |
Yingdi Yu | 5ff6210 | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 25 | public: |
| 26 | Profile() {} |
| 27 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 28 | Profile(const ndn::IdentityCertificate& identityCertificate); |
Yingdi Yu | e9ea5c9 | 2013-11-06 18:42:34 -0800 | [diff] [blame] | 29 | |
Yingdi Yu | 5ff6210 | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 30 | Profile(const ndn::Name& identityName); |
| 31 | |
| 32 | Profile(const ndn::Name& identityName, |
| 33 | const std::string& name, |
| 34 | const std::string& institution); |
| 35 | |
| 36 | Profile(const Profile& profile); |
| 37 | |
| 38 | virtual |
| 39 | ~Profile() {} |
| 40 | |
| 41 | void |
| 42 | setProfileEntry(const std::string& profileType, |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 43 | const std::string& profileValue); |
Yingdi Yu | 5ff6210 | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 44 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 45 | std::string |
Yingdi Yu | 53b8a9c | 2013-10-14 09:36:31 -0700 | [diff] [blame] | 46 | getProfileEntry(const std::string& profileType) const; |
Yingdi Yu | 5ff6210 | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 47 | |
| 48 | inline Profile::iterator |
| 49 | begin() |
| 50 | { return m_entries.begin(); } |
| 51 | |
| 52 | inline Profile::const_iterator |
| 53 | begin() const |
| 54 | { return m_entries.begin(); } |
| 55 | |
| 56 | inline Profile::iterator |
| 57 | end() |
| 58 | { return m_entries.end(); } |
| 59 | |
| 60 | inline Profile::const_iterator |
| 61 | end() const |
| 62 | { return m_entries.end(); } |
| 63 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 64 | void |
| 65 | encode(std::string* output) const; |
Yingdi Yu | 5ff6210 | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 66 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 67 | static ndn::ptr_lib::shared_ptr<Profile> |
| 68 | decode(const std::string& input); |
Yingdi Yu | 5ff6210 | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 69 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 70 | const std::map<std::string, std::string>& |
Yingdi Yu | 79c25a2 | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 71 | getEntries() const |
| 72 | { return m_entries; } |
| 73 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 74 | const ndn::Name& |
Yingdi Yu | e9ea5c9 | 2013-11-06 18:42:34 -0800 | [diff] [blame] | 75 | getIdentityName() const |
| 76 | { return m_identityName; } |
| 77 | |
Yingdi Yu | 5ff6210 | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 78 | protected: |
| 79 | ndn::Name m_identityName; |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 80 | std::map<std::string, std::string> m_entries; |
Yingdi Yu | 5ff6210 | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 81 | }; |
| 82 | |
Yingdi Yu | 5ff6210 | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 83 | #endif |