/*********************************************************************/
/* */
/* 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.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using AgentService.Ontology.Schema.Abstract;
namespace AgentService.Ontology.Schema {
///
/// This class is the common ancestor of all ontological schemas.
///
[Serializable]
public abstract class ObjectSchema {
public static readonly int mandatory = 0;
public static readonly int optional = 1;
public static readonly int unlimited = -1; //the cardinality.
public static readonly string base_name = "Object";
protected static ObjectSchema baseSchema = null;
private bool encodingByOrder = false;
///
/// Retrieves the generic base schema for all object.
///
/// Return the base schema.
public static ObjectSchema GetBaseSchema()
{
return baseSchema;
}
///
/// Adds a slot to the schema.
///
/// The name of the slot.
/// The schema of the slot.
/// mandatory or optional.
public abstract void Add(string name, ObjectSchema slotSchema, int optionality);
///
/// Adds a slot to the schema.
///
/// The name of the slot.
/// The schema of the slot.
public abstract void Add(string name, ObjectSchema slotSchema);
///
/// Adds a slot to the schema.
///
/// The name of the slot.
/// The schema of the slot.
/// The slot at least get cardMinvalues.
/// The slot at most get cardMaxvalues.
public abstract void Add(string name, ObjectSchema elementsSchema, int cardMin, int cardMax);
///
/// Adds a slot to the schema.
///
/// The name of the slot.
/// The schema of the slot.
/// The slot at least get cardMinvalues.
/// The slot at most get cardMaxvalues.
/// The aggregate type of the slot.
public abstract void Add(string name, ObjectSchema elementsSchema, int cardMin, int cardMax, string aggType);
///
/// Adds a super schema to the schema. The schema will inherit all the characteristics from the super schema.
///
///
public abstract void AddSuperSchema(ObjectSchema superSchema);
///
/// Adds a facet.
///
/// The name of the facet.
/// The facet.
public abstract void AddFacet(string slotName, Facet f);
///
/// Sets the property EncodingByOrder of slots.
///
/// TRUE or FALSE
public void setEncodingByOrder(bool b)
{
encodingByOrder = b;
}
///
/// Gets the value of the EncodingByOrder property
///
/// TRUE or FALSE.
public bool GetEncodingByOrder()
{
return encodingByOrder;
}
///
/// Retrieves the name of the type of this schema.
///
/// The name of the type of the schema.
public abstract string GetTypeName();
///
/// Returns all the names of the slots ( including the slots of super schemas ).
///
///
public abstract string[] GetNames();
///
/// Validates a given abstract object, using a given ontology.
///
/// The abstract object to Validate.
/// The ontology to use.
public abstract void Validate(AbsObject abs, Ontology onto);
///
/// Gets the schema of a given slot.
///
/// The name of the slot.
///
public abstract ObjectSchema GetSchema(string name);
///
/// Returns true if this schema contanins a slot with a given name.
///
/// The name of the slot.
///
public abstract bool ContainsSlot(string name);
///
/// Checks if the given slot is mandatory.
///
/// The name of the slot.
///
public abstract bool IsMandatory(string name);
///
/// Checks if a given schema is compatible with this schema.
///
/// The object to check.
///
public abstract bool IsCompatibleWith(ObjectSchema s);
///
/// Returns true if the given schema descends from this schema.
///
/// The object.
///
public abstract bool DescendsFrom(ObjectSchema s);
///
/// Returns an array containing the facets of a given slot.
///
/// The name of the slot.
///
public abstract Facet[] GetFacets(string slotName);
///
/// Returns an abstract object that represents this schema.
///
///
public abstract AbsObject NewInstance();
}
}