/*********************************************************************/ /* */ /* 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; // this namespace contains the elements for the instantiation // of new knowledges. using AgentService.Agent.Knowledge; // this namespac contains the elements for the instantiation // of new behaviours. using AgentService.Agent.Behaviour; namespace AuctionDemo { /// /// The AuctionData knowledge maintains information about an auction /// session (i.e. the object, the starting price, the minimum increase, /// and the expected number of bidders. /// [Serializable] public class AuctionData : AgentService.Agent.Knowledge.Knowledge { /// /// Deserialization constructor. /// public AuctionData() : base() { } /// /// Constructor with parameters /// /// the name of the knowledge instance /// persistence mode /// the name of the object /// initial price of the object /// minumum increase /// expected number of bidders public AuctionData(string name, PersistenceMode pMode, string item, float price, float minIncrement, int maxParticipants):base(name, pMode) { this.AddItem("Item",typeof(string),item); this.AddItem("Price",typeof(float),price); this.AddItem("MinIncrement", typeof(float), minIncrement); this.AddItem("MaxParticipants", typeof(int), maxParticipants); } #region Getter and Settere for the properties of the knowledge /// /// The Getter for the Item property. /// /// Instance of the behaviour that requests the access. /// the property value. [KnowledgeItem("Item",typeof(string),true)] public string GetItem(Behaviour lockingBehaviour) { return this["Item", lockingBehaviour] as string; } /// /// Setter for the Item property /// /// Instance of the behaviour that requests the access. /// the property value. /// the new property value. [KnowledgeItem("Item", typeof(string), false)] public string SetItem(Behaviour lockingBehaviour, string value) { this["Item", lockingBehaviour] = value; return this["Item", lockingBehaviour] as string; } /// /// Getter for the Price property. /// /// Instance of the behaviour that requests the access. /// the property value of Price [KnowledgeItem("Price",typeof(float), true)] public float GetPrice(Behaviour lockingBehaviour) { return (float) this["Price", lockingBehaviour]; } /// /// Setter for the Price property. /// /// Instance of the behaviour that requests the access. /// the property value of the Price /// the new value of the property Price [KnowledgeItem("Price",typeof(float), false)] public float SetPrice(Behaviour lockingBehaviour, float value) { this["Price", lockingBehaviour] = value; return (float) this["Price", lockingBehaviour]; } /// /// Getter for the MinIncrement property. /// /// Instance of the behaviour that requests the access. /// the value of MinIncrement [KnowledgeItem("MinIncrement",typeof(float),true)] public float GetMinIncrement(Behaviour lockingBehaviour) { return (float) this["MinIncrement", lockingBehaviour]; } /// /// Setter for the MinIncrement property. /// /// Instance of the behaviour that requests the access. /// the value of MinIncrement /// the new value [KnowledgeItem("MinIncrement",typeof(float),false)] public float SetMinIncrement(Behaviour lockingBehaviour, float value) { this["MinIncrement", lockingBehaviour] = value; return (float) this["MinIncrement", lockingBehaviour]; } /// /// Getter for the MaxParticipants property. /// /// Instance of the behaviour that requests the access. /// value of MaxParticipants [KnowledgeItem("MaxParticipants",typeof(int),true)] public int GetMaxParticipants(Behaviour lockingBehaviour) { return (int) this["MaxParticipants", lockingBehaviour]; } /// /// Setter for the MaxParticipants property. /// /// Instance of the behaviour that requests the access. /// the new value /// the current value [KnowledgeItem("MaxParticipants",typeof(int),false)] public int SetMaxParticipants(Behaviour lockingBehaviour, int value) { this["MaxParticipants", lockingBehaviour] = value; return (int) this["MaxParticipants", lockingBehaviour]; } #endregion } }