/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 2013, Regents of the University of California
 *                     Yingdi Yu
 *
 * BSD license, See the LICENSE file for more information
 *
 * Author: Yingdi Yu <yingdi@cs.ucla.edu>
 */

#ifndef LINKNDN_PROFILE_H
#define LINKNDN_PROFILE_H

#include <ndn-cpp/name.hpp>
#include <ndn-cpp/security/certificate/identity-certificate.hpp>
#include <map>
#include <string>
#include "profile.pb.h"

class Profile
{
public:
  typedef std::map<std::string, std::string>::iterator iterator;
  typedef std::map<std::string, std::string>::const_iterator const_iterator;
public:
  Profile() {}

  Profile(const ndn::IdentityCertificate& identityCertificate);

  Profile(const ndn::Name& identityName);

  Profile(const ndn::Name& identityName,
          const std::string& name,
          const std::string& institution);
  
  Profile(const Profile& profile);
  
  virtual
  ~Profile() {}

  void
  setProfileEntry(const std::string& profileType,
                  const std::string& profileValue);
  
  std::string
  getProfileEntry(const std::string& profileType) const;

  inline Profile::iterator
  begin()
  { return m_entries.begin(); }

  inline Profile::const_iterator
  begin() const
  { return m_entries.begin(); }

  inline Profile::iterator
  end()
  { return m_entries.end(); }

  inline Profile::const_iterator
  end() const
  { return m_entries.end(); }

  void
  encode(std::string* output) const;

  static ndn::ptr_lib::shared_ptr<Profile>
  decode(const std::string& input);

  const std::map<std::string, std::string>&
  getEntries() const
  { return m_entries; }

  const ndn::Name&
  getIdentityName() const
  { return m_identityName; }

protected:
  ndn::Name m_identityName;
  std::map<std::string, std::string> m_entries;
};

#endif
