using System;
using AgentService.Agent;
using AgentService.Agent.Runtime;
using AgentService.Agent.Behaviour;
using AgentService.Agent.Knowledge;
using AgentService.Platform.AMS;
namespace TestMessaging
{
///
/// Knowledge ConvData. Mantains
/// information about a conversation
/// among two agents.
///
public class ConvData : Knowledge
{
#region Getter and Setter
///
/// Getter for the PeerName property. The PeerName is
/// used to store the name of the peer agent in a
/// conversation.
///
/// Instance of the behaviour
/// that requests the access.
/// the property value.
[KnowledgeItem("PeerName", typeof(string), true)]
public string GetPeerName(Behaviour lockingBehaviour)
{
return this["PeerName", lockingBehaviour] as string;
}
///
/// Setter for the PeerName property. The PeerName is
/// used to store the name of the peer agent in a
/// conversation.
///
/// Instance of the behaviour
/// that requests the access.
/// the property value.
/// the new property value.
[KnowledgeItem("PeerName", typeof(string), false)]
public string SetPeerName(Behaviour lockingBehaviour, string value)
{
this["PeerName", lockingBehaviour] = value;
return this["PeerName", lockingBehaviour] as string;
}
///
/// Getter for the Repetitions property. The Repetitions is
/// used to store the number of conversations attempted to
/// open.
///
/// Instance of the behaviour
/// that requests the access.
/// the property value.
[KnowledgeItem("Repetitions", typeof(int), true)]
public int GetRepetitions(Behaviour lockingBehaviour)
{
return (int) this["Repetitions", lockingBehaviour];
}
///
/// Setter for the Repetitions property. The Repetitions is
/// used to store the number of conversations attempted to
/// open.
///
/// Instance of the behaviour
/// that requests the access.
/// the property value.
[KnowledgeItem("Repetitions", typeof(int), false)]
public int SetRepetitions(Behaviour lockingBehaviour, int value)
{
this["Repetitions", lockingBehaviour] = value;
return (int) this["Repetitions", lockingBehaviour];
}
///
/// Getter for the MaxMessages property. he MaxMessages is
/// used to store the number of messages sent within a
/// conversation.
///
/// Instance of the behaviour that requests the access.
/// the property value.
[KnowledgeItem("MaxMessages", typeof(int), true)]
public int GetMaxMessages(Behaviour lockingBehaviour)
{
return (int) this["MaxMessages", lockingBehaviour];
}
///
/// Setter for the MaxMessages property. The MaxMessages is
/// used to store the number of messages sent within a
/// conversation.
///
/// Instance of the behaviour
/// that requests the access.
/// the property value.
[KnowledgeItem("MaxMessages", typeof(int), false)]
public int SetMaxMessages(Behaviour lockingBehaviour, int value)
{
this["MaxMessages", lockingBehaviour] = value;
return (int) this["MaxMessages", lockingBehaviour];
}
///
/// Getter for the Refuse property. The Refuse flag to
/// control conversation acceptance or refusal.
///
/// Instance of the behaviour
/// that requests the access.
/// the property value.
[KnowledgeItem("Refuse", typeof(bool), true)]
public bool GetRefuse(Behaviour lockingBehaviour)
{
return (bool) this["Refuse", lockingBehaviour];
}
///
/// Setter for the Refuse property. The Refuse flag to
/// control conversation acceptance or refusal.
///
/// Instance of the behaviour
/// that requests the access.
/// the property value.
[KnowledgeItem("Refuse", typeof(int), false)]
public bool SetRefuse(Behaviour lockingBehaviour, bool value)
{
this["Refuse", lockingBehaviour] = value;
return (bool) this["Refuse", lockingBehaviour];
}
#endregion
///
/// Deserialization constructor.
///
public ConvData()
{
}
///
/// Creates an instance of the ConvData knowledge.
///
/// knowledge name
/// persistence mode
/// name of the peer agent
/// number of conversations that will be openened
/// number of messages sent within a conversation
/// refuse conversation flag
public ConvData(string name, PersistenceMode pMode, string peerName, int repetitions, int maxMessages, bool bRefuse) : base(name, pMode)
{
this.AddItem("PeerName", typeof(string), peerName);
this.AddItem("Repetitions", typeof(int), repetitions);
this.AddItem("MaxMessages", typeof(int), maxMessages);
this.AddItem("Refuse", typeof(bool), bRefuse);
}
}
}