/*********************************************************************/
/* */
/* 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 AgentService.Agent;
using AgentService.Agent.Knowledge;
using AgentService.Agent.Behaviour;
using AgentService.Agent.Runtime;
using AgentService.Platform.AMS;
using AgentService.Platform.MTS;
namespace AgentService.Platform.DF
{
///
/// Class DF. Specific DF Agent class
///
public class DF : AgentService.Agent.Agent
{
private DFAgentDescriptionCollection agentDescriptions;
internal DFAgentDescriptionCollection AgentDescriptions
{
get
{
return this.agentDescriptions;
}
}
private IYellowPagesServer ypServer;
///
/// Gets the White Pages service.
///
public IYellowPagesServer YellowPages
{
get
{
return this.ypServer;
}
}
///
/// Reference to the owning platform.
///
private AgentService.Platform.IPlatform platform;
///
/// Constructs a DF Agent for the given platform.
///
/// Reference to the owning platform
public DF(AgentService.Platform.IPlatform platform)
{
this.platform = platform;
this.aid = new AID(this.platform.dfName, this.platform.Description.Name);
this.agentDescriptions = new DFAgentDescriptionCollection();
this.ypServer = new DefaultYellowPagesServer(this.agentDescriptions, this.aid, this.platform);
}
#region Override
///
/// Loads agent data from its persisted version
///
/// Persisted version of the agent.
public override void ResumeFrom(AgentPersistent persistent)
{
base.ResumeFrom(persistent);
// resync the internal data with the correponding knowledge
KnowledgePersistent kp = this.Knowledges[0].GetPersistent();
this.agentDescriptions = kp.Items[0] as DFAgentDescriptionCollection;
}
#endregion
///
/// Deregisters an agent with the DF (Yellow Page Service)
///
/// agent identifier
/// if true the agent is successfully deregistered
public bool Deregister(AID aid)
{
lock(this.ypServer)
{
this.ypServer.Deregister(aid);
return true;
}
}
#region CallBacks
///
/// Handler of messages directed to the AMS
///
///
public void DispatchMessage(AgentMessage msg)
{
// ...
}
#endregion
}
}