/*********************************************************************/ /* */ /* 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.Platform.DF; namespace AgentService.Agent.Runtime { /// /// This class represents the content of a message exchanged by two DFs. /// [Serializable] public class DFBodyMessage { /// /// The unique identifyier of the transaction. /// public Guid TransactionID { get; set; } /// /// The message type. /// public DFMessageType MessageType { get; set; } /// /// The list of returned AgentDescriptions. /// public DFAgentDescription[] AgentDescriptions { get; private set; } /// /// The searched service description /// public ServiceDescription ServiceDescription { get; private set; } /// /// Service comparison /// public ServiceComparison ServiceComparison { get; private set; } /// /// The search constraints /// public SearchConstraints SearchConstraints { get; private set; } /// /// The search type /// public SearchAgentType SearchType { get; private set; } /// /// Constructs a new DF body message and instantiate a new TransactionID /// public DFBodyMessage() { this.MessageType = DFMessageType.Reply; this.TransactionID = Guid.NewGuid(); } /// /// Set the required field for a search. /// /// The service description /// The service constraints public void SearchAgent(ServiceDescription sd, SearchConstraints constraints) { this.MessageType = DFMessageType.Query; this.SearchType = SearchAgentType.ServiceAndConstraints; this.ServiceDescription = sd; this.SearchConstraints = constraints; } /// /// Set the required field for a search. /// /// The service description /// The service constraints /// The flags public void SearchAgent(ServiceDescription sd, ServiceComparison flags, SearchConstraints constraints) { this.MessageType = DFMessageType.Query; this.SearchType = SearchAgentType.ServiceFlagsAndConstraints; this.ServiceDescription = sd; this.SearchConstraints = constraints; this.ServiceComparison = flags; } /// /// Sets the reply to a query /// /// The list of agents /// The transaction ID public void setReply(DFAgentDescription []agents, Guid transactionID) { this.TransactionID = transactionID; this.AgentDescriptions = agents; this.MessageType = DFMessageType.Reply; } } /// /// States the type of message /// public enum DFMessageType { Query, Reply } /// /// States the type of search. /// public enum SearchAgentType { ServiceAndConstraints, ServiceFlagsAndConstraints } }