blob: 2afef316364e840e0dcc00b0ad167601341c402e [file] [log] [blame]
Yingdi Yu5ff62102013-10-13 17:24:50 -07001/* -*- 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 Yu6df61252014-01-21 11:05:11 -080014#include <ndn-cpp-dev/name.hpp>
15#include <ndn-cpp-dev/security/identity-certificate.hpp>
Yingdi Yu5ff62102013-10-13 17:24:50 -070016#include <map>
17#include <string>
Yingdi Yu64206112013-12-24 11:16:32 +080018#include "profile.pb.h"
Yingdi Yu5ff62102013-10-13 17:24:50 -070019
20class Profile
21{
22public:
Yingdi Yu64206112013-12-24 11:16:32 +080023 typedef std::map<std::string, std::string>::iterator iterator;
24 typedef std::map<std::string, std::string>::const_iterator const_iterator;
Yingdi Yu5ff62102013-10-13 17:24:50 -070025public:
26 Profile() {}
27
Yingdi Yu64206112013-12-24 11:16:32 +080028 Profile(const ndn::IdentityCertificate& identityCertificate);
Yingdi Yue9ea5c92013-11-06 18:42:34 -080029
Yingdi Yu5ff62102013-10-13 17:24:50 -070030 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 Yu64206112013-12-24 11:16:32 +080043 const std::string& profileValue);
Yingdi Yu5ff62102013-10-13 17:24:50 -070044
Yingdi Yu64206112013-12-24 11:16:32 +080045 std::string
Yingdi Yu53b8a9c2013-10-14 09:36:31 -070046 getProfileEntry(const std::string& profileType) const;
Yingdi Yu5ff62102013-10-13 17:24:50 -070047
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 Yu64206112013-12-24 11:16:32 +080064 void
65 encode(std::string* output) const;
Yingdi Yu5ff62102013-10-13 17:24:50 -070066
Yingdi Yu64206112013-12-24 11:16:32 +080067 static ndn::ptr_lib::shared_ptr<Profile>
68 decode(const std::string& input);
Yingdi Yu5ff62102013-10-13 17:24:50 -070069
Yingdi Yu64206112013-12-24 11:16:32 +080070 const std::map<std::string, std::string>&
Yingdi Yu79c25a22013-10-21 13:38:38 -070071 getEntries() const
72 { return m_entries; }
73
Yingdi Yu64206112013-12-24 11:16:32 +080074 const ndn::Name&
Yingdi Yue9ea5c92013-11-06 18:42:34 -080075 getIdentityName() const
76 { return m_identityName; }
77
Yingdi Yu5ff62102013-10-13 17:24:50 -070078protected:
79 ndn::Name m_identityName;
Yingdi Yu64206112013-12-24 11:16:32 +080080 std::map<std::string, std::string> m_entries;
Yingdi Yu5ff62102013-10-13 17:24:50 -070081};
82
Yingdi Yu5ff62102013-10-13 17:24:50 -070083#endif