// -*- c++ -*-
#ifndef PROJECT_MAP_H__
#define PROJECT_MAP_H__

#include <akaxiso/content_model.h>
#include <list>

namespace pj {

  typedef std::map<std::string, std::string> MemberMap;
  typedef std::pair<std::string, std::string> MemberPair;

  struct OrderedTeam {
    std::string name_;
    std::string url_;
    MemberMap members_;
  };


  struct SimpleContentItemLeaf : 
    public aka::simplecontent<pj::MemberPair, SimpleContentItemLeaf> {
    void model() {
      //    static_typeinfo().set_typename("cuppa:member");
      value(&pj::MemberPair::first);
      attribute("title", &pj::MemberPair::second);
    }
  };

  struct SequenceItemLeaf : 
    public aka::sequence<pj::MemberPair, SequenceItemLeaf> {
    void model() {
      //    static_typeinfo().set_typename("cuppa:member");
      member("cuppa:name", &pj::MemberPair::first);
      member("cuppa:title", &pj::MemberPair::second);
    }
  };


  typedef aka::associative_array<pj::MemberMap, pj::SimpleContentItemLeaf> 
  SimpleContentMemberMapLeaf; 

  typedef aka::associative_array<pj::MemberMap, pj::SequenceItemLeaf> 
  SequenceMemberMapLeaf; 

  struct OrderedSimpleContentTeamLeaf : public aka::sequence<pj::OrderedTeam, 
					pj::OrderedSimpleContentTeamLeaf> {
    void model() {
      //    static_typeinfo().set_typename("cuppa:team");
      member("cuppa:project_name", &pj::OrderedTeam::name_);
      member("cuppa:url", &pj::OrderedTeam::url_);
      enclose("cuppa:members");
      ;  member("cuppa:member", &pj::OrderedTeam::members_, 
		SimpleContentMemberMapLeaf(),
		0, aka::unbounded);
      disclose("cuppa:members");
    }
  };


  struct OrderedSequenceTeamLeaf : public aka::sequence<pj::OrderedTeam, 
				   pj::OrderedSequenceTeamLeaf> {
    void model() {
      //    static_typeinfo().set_typename("cuppa:team");
      member("cuppa:project_name", &pj::OrderedTeam::name_);
      member("cuppa:url", &pj::OrderedTeam::url_);
      enclose("cuppa:members");
      {
	member("cuppa:member", 
	       &pj::OrderedTeam::members_, 
	       SequenceMemberMapLeaf(),
	       0, aka::unbounded);
      }
      disclose("cuppa:members");
    }
  };

}



#endif
