/*********************************************************************/
/* */
/* AgentService Framework */
/* www.agentservice.it */
/* */
/* Copyright (C) 2007 l.i.d.o. - DIST, University of Genoa, Italy */
/* GNU Lesser General Public License */
/* */
/* This library is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Lesser General Public */
/* License as published by the Free Software Foundation, */
/* version 2.1 of the License. */
/* */
/* This library is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
/* Lesser General Public License for more details. */
/* */
/* You should have received a copy of the GNU Lesser General Public */
/* License along with this library; if not, write to the */
/* Free Software Foundation, Inc., 59 Temple Place - Suite 330, */
/* Boston, MA 02111-1307, USA. */
/* */
/*********************************************************************/
using System;
using System.Runtime.Serialization;
using AgentService.Ontology;
using AgentService.Platform.AMS;
using AgentService.Platform.MTS;
using AgentService.Agent.Runtime;
namespace AgentService.Agent.Runtime
{
///
/// Class ConversationBody. Defines the Body of the messages used by the Conversation class
/// to control the conversation life-cycle
///
[Serializable]
[DataContract]
public class ConversationBody:MessageBody
{
public string ConvId
{
get
{
return (string)this["Guid"];
}
}
///
/// Gets, sets the meaning of the conversation body.
///
public ConversationProtocol Verb
{
get
{
return (ConversationProtocol) this["Verb"];
}
set
{
this["Verb"] = value;
}
}
///
/// Gets, sets the initiator of the conversation
///
public AID Initiator
{
get
{
return (AID) this["Initiator"];
}
set
{
this["Initiator"] = value;
}
}
public OntologyTypeDescriptor Ontology
{
get
{
return (OntologyTypeDescriptor)this["Ontology"];
}
set
{
this["Ontology"] = value;
}
}
///
/// Constructs an empty ConverationBody object
/// Note: do not call this constructor, used only
/// for deserialization
///
public ConversationBody()
{
this.Add("Verb", ConversationProtocol.Propose);
this.Add("Initiator",new AID());
this.Add("Ontology", new OntologyTypeDescriptor());
this.Add("Guid", System.Guid.NewGuid().ToString());
}
///
/// Deserialization constructor
///
/// SerializationInfo to populate with data
/// contextual information about the source or destination of the serialization
public ConversationBody(SerializationInfo info, StreamingContext context):base(info,context)
{
}
///
/// Constructs a ConversationBody object with the given identifier and sets the conversation verb to "Conversation.Propose".
///
/// original identifier that started the conversation set up protocol
/// conversation identifier
/// aid of the initiator of the conversation
public ConversationBody(string guid, AID aid)
{
this.Add("Verb", ConversationProtocol.Propose);
this.Add("Initiator",aid);
this.Add("Ontology", new OntologyTypeDescriptor());
this.Add("Guid", guid);
}
///
/// Constructs a ConversationBody object with the given identifier and the conversation verb.
///
/// original identifier that started the conversation set up protocol
/// conversation identifier
/// conversation verb
/// aid of the initiator of the conversation
public ConversationBody(string guid, AID aid, ConversationProtocol verb)
{
this.Add("Verb", verb);
this.Add("Initiator",aid);
this.Add("Ontology", new OntologyTypeDescriptor());
this.Add("Guid", guid);
}
///
/// Constructs a ConversationBody object with the given identifier, the conversation protocol, and the alternate identifier.
///
/// original identifier that started the conversation set up protocol
/// conversation identifier
/// conversation verb
/// alternate conversation identifier
/// aid of the initiator of the conversation
/// the name of the ontology
public ConversationBody(string guid, AID aid, ConversationProtocol verb, OntologyTypeDescriptor ontology)
{
this.Add("Verb", verb);
this.Add("Initiator", aid);
this.Add("Ontology", ontology);
this.Add("Guid", guid);
}
}
}