/*********************************************************************/ /* */ /* 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.IO; using System.Reflection; using AgentService.Interop; using AgentService.Platform.AMS; using AgentService.Platform.MTS; using AgentService.Platform.Modules; namespace AgentService.Platform { /// /// Manage the operation with the modules exposed by the platform ocntroller /// [Serializable] public class ModuleController : IModuleController { /// /// Reference to the bound platform /// private Platform platform; /// /// Constructs a module controller object with the boud platform /// /// Reference to the platform object to be bound public ModuleController(Platform platform) { this.platform = platform; } #region Storage /// /// Retrieves the information for all the installed modules /// in the platform. /// /// include additional modules /// an array containing all the installed modules public IModuleInfo[] GetInstalledModules(bool bAdditional) { IModuleInfo[] infos; IModuleInfo[] additionals = this.platform.Configuration.AdditionalModules; int length = 4; if(bAdditional == true) { length = length + additionals.Length; } infos = new ModuleInfo[length]; infos[0] = this.platform.Configuration.MessagingModule; infos[1] = this.platform.Configuration.LoggingModule; infos[2] = this.platform.Configuration.PersistenceModule; infos[3] = this.platform.Configuration.StorageModule; /* for(int i=4;i /// Gets all the Assembly contained in the repository /// /// List of assemblies public AssemblyName[] GetStoredAssemblies() { return this.platform.Storage.GetStoredAssemblies(); } /// /// Gets the list of the stored AgentTemplate types /// used to instantiate agents. /// /// an array containing a AgentTemplateDescriptor object for each AgentTemplate public AgentTemplateDescriptor[] GetStoredAgentTemplates() { return this.platform.Storage.GetStoredAgentTemplates(); } /// /// Gets the list of the stored Behaviour types /// used to instantiate agents. /// /// an array containing a BehaviourDescriptor object for each Behavoiur public BehaviourDescriptor[] GetStoredBehaviours() { return this.platform.Storage.GetStoredBehaviours(); } /// /// Gets the list of the stored Knowledge types /// used to instantiate agents. /// /// an array containing a KnowledgeDescriptor object for each Knowledge public KnowledgeDescriptor[] GetStoredKnowledges() { return this.platform.Storage.GetStoredKnowledges(); } #endregion #region Logging public string GetLogFile(AID aid) { //TODO: implement this inside the logging module (interface and default module) return null; } #endregion /// /// Uploads an assembly to the platform's storage /// /// path to the assembly /// null if successfull a description of the error otherwise public IModuleError UpLoadAssembly(string asmPath, bool bReplaceIfExists) { if (this.platform.State == PlatformState.Ready) { if (this.platform.Storage.AddAssembly(asmPath, bReplaceIfExists) == false) { return this.platform.Storage.GetLastError(); } else { return null; } } return new ModuleError((int) ModuleErrorCodes.InvalidState, null, "cannot Add assemblies while platform is not in the Ready state"); } /// /// Removes an assembly from the platform's storage /// /// path to the assembly /// null if successfull a description of the error otherwise public IModuleError RemoveAssembly(string asmPath) { if (this.platform.State == PlatformState.Ready) { if (this.platform.Storage.RemoveAssembly(asmPath) == false) { return this.platform.Storage.GetLastError(); } else { return null; } } return new ModuleError((int) ModuleErrorCodes.InvalidState, null, "cannot Add assemblies while platform is not in the Ready state"); } #region Messaging /// /// Gets a collection of filtered messages /// /// aid of the agent /// filter criteria /// list of filtered messages public AgentMessageCollection FilterMessage(AID aid, MessageFilter filter) { //TODO: to be implemented; return null; } /// /// Clears all the messages in the storage. /// public void ClearAllMessages() { //TODO: to be implemented; } /// /// Clears all the messages in the storage for a given agent. /// /// AID identifing the agent /// true, if the process is successful public bool ClearAllMessages(AID aid) { //TODO: to be implemented; return false; } #endregion } }