-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from DeMaCS-UNICAL/csharp
C# Version
- Loading branch information
Showing
42 changed files
with
2,069 additions
and
22 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{AFB8ACB3-383E-4D4B-8BC2-1F70CFBACCCF}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>EmbASP</RootNamespace> | ||
<AssemblyName>EmbASP</AssemblyName> | ||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> | ||
<HintPath>packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Net" /> | ||
<Reference Include="System.Runtime.Serialization" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="it\unical\mat\embasp\base\Callback.cs" /> | ||
<Compile Include="it\unical\mat\embasp\base\Handler.cs" /> | ||
<Compile Include="it\unical\mat\embasp\base\InputProgram.cs" /> | ||
<Compile Include="it\unical\mat\embasp\base\OptionDescriptor.cs" /> | ||
<Compile Include="it\unical\mat\embasp\base\Output.cs" /> | ||
<Compile Include="it\unical\mat\embasp\base\Service.cs" /> | ||
<Compile Include="it\unical\mat\embasp\languages\asp\AnswerSet.cs" /> | ||
<Compile Include="it\unical\mat\embasp\languages\asp\AnswerSets.cs" /> | ||
<Compile Include="it\unical\mat\embasp\languages\asp\ASPFilterOption.cs" /> | ||
<Compile Include="it\unical\mat\embasp\languages\asp\ASPInputProgram.cs" /> | ||
<Compile Include="it\unical\mat\embasp\languages\asp\ASPMapper.cs" /> | ||
<Compile Include="it\unical\mat\embasp\languages\asp\IllegalTermException.cs" /> | ||
<Compile Include="it\unical\mat\embasp\languages\asp\PredicateNotValidException.cs" /> | ||
<Compile Include="it\unical\mat\embasp\languages\asp\SymbolicConstant.cs" /> | ||
<Compile Include="it\unical\mat\embasp\languages\Id.cs" /> | ||
<Compile Include="it\unical\mat\embasp\languages\IllegalAnnotationException.cs" /> | ||
<Compile Include="it\unical\mat\embasp\languages\Mapper.cs" /> | ||
<Compile Include="it\unical\mat\embasp\languages\ObjectNotValidException.cs" /> | ||
<Compile Include="it\unical\mat\embasp\languages\Param.cs" /> | ||
<Compile Include="it\unical\mat\embasp\languages\pddl\Action.cs" /> | ||
<Compile Include="it\unical\mat\embasp\languages\pddl\PDDLException.cs" /> | ||
<Compile Include="it\unical\mat\embasp\languages\pddl\PDDLInputProgram.cs" /> | ||
<Compile Include="it\unical\mat\embasp\languages\pddl\PDDLMapper.cs" /> | ||
<Compile Include="it\unical\mat\embasp\languages\pddl\PDDLProgramType.cs" /> | ||
<Compile Include="it\unical\mat\embasp\languages\pddl\Plan.cs" /> | ||
<Compile Include="it\unical\mat\embasp\platforms\desktop\DesktopHandler.cs" /> | ||
<Compile Include="it\unical\mat\embasp\platforms\desktop\DesktopService.cs" /> | ||
<Compile Include="it\unical\mat\embasp\specializations\clingo\ClingoAnswerSets.cs" /> | ||
<Compile Include="it\unical\mat\embasp\specializations\clingo\desktop\ClingoDesktopService.cs" /> | ||
<Compile Include="it\unical\mat\embasp\specializations\dlv2\desktop\DLV2DesktopService.cs" /> | ||
<Compile Include="it\unical\mat\embasp\specializations\dlv2\DLV2AnswerSets.cs" /> | ||
<Compile Include="it\unical\mat\embasp\specializations\dlv\desktop\DLVDesktopService.cs" /> | ||
<Compile Include="it\unical\mat\embasp\specializations\dlv\DLVAnswerSets.cs" /> | ||
<Compile Include="it\unical\mat\embasp\specializations\dlv\DLVFilterOption.cs" /> | ||
<Compile Include="it\unical\mat\embasp\specializations\solver_planning_domains\desktop\SPDDesktopService.cs" /> | ||
<Compile Include="it\unical\mat\embasp\specializations\solver_planning_domains\SPDPlan.cs" /> | ||
<Compile Include="it\unical\mat\embasp\specializations\solver_planning_domains\SPDUtility.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.27703.1 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmbASP", "EmbASP.csproj", "{AFB8ACB3-383E-4D4B-8BC2-1F70CFBACCCF}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{AFB8ACB3-383E-4D4B-8BC2-1F70CFBACCCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{AFB8ACB3-383E-4D4B-8BC2-1F70CFBACCCF}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{AFB8ACB3-383E-4D4B-8BC2-1F70CFBACCCF}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{AFB8ACB3-383E-4D4B-8BC2-1F70CFBACCCF}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {0DCF52EC-D57A-43D5-B405-73425C9AB757} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// Le informazioni generali relative a un assembly sono controllate dal seguente | ||
// set di attributi. Modificare i valori di questi attributi per modificare le informazioni | ||
// associate a un assembly. | ||
[assembly: AssemblyTitle("EmbASP")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("EmbASP")] | ||
[assembly: AssemblyCopyright("Copyright © 2018")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Se si imposta ComVisible su false, i tipi in questo assembly non saranno visibili | ||
// ai componenti COM. Se è necessario accedere a un tipo in questo assembly da | ||
// COM, impostare su true l'attributo ComVisible per tale tipo. | ||
[assembly: ComVisible(false)] | ||
|
||
// Se il progetto viene esposto a COM, il GUID seguente verrà utilizzato come ID della libreria dei tipi | ||
[assembly: Guid("afb8acb3-383e-4d4b-8bc2-1f70cfbacccf")] | ||
|
||
// Le informazioni sulla versione di un assembly sono costituite dai seguenti quattro valori: | ||
// | ||
// Versione principale | ||
// Versione secondaria | ||
// Numero di build | ||
// Revisione | ||
// | ||
// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build | ||
// usando l'asterisco '*' come illustrato di seguito: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace it.unical.mat.embasp.@base | ||
{ | ||
public interface ICallback | ||
{ | ||
void Callback(Output o); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace it.unical.mat.embasp.@base | ||
{ | ||
public abstract class Handler | ||
{ | ||
protected internal IDictionary<int, InputProgram> programs; | ||
protected internal IDictionary<int, OptionDescriptor> options; | ||
|
||
public Handler() | ||
{ | ||
programs = new Dictionary<int, InputProgram>(); | ||
options = new Dictionary<int, OptionDescriptor>(); | ||
} | ||
|
||
public virtual int AddOption(OptionDescriptor o) | ||
{ | ||
int last_index = options.Count; | ||
int current_value = last_index; | ||
options[last_index++] = o; | ||
return current_value; | ||
} | ||
|
||
public virtual int AddProgram(InputProgram program) | ||
{ | ||
int last_index = programs.Count; | ||
int current_value = last_index; | ||
programs[last_index++] = program; | ||
return current_value; | ||
} | ||
|
||
protected internal virtual IList<OptionDescriptor> CollectOptions(IList<int> option_index) | ||
{ | ||
IList<OptionDescriptor> input_option = new List<OptionDescriptor>(); | ||
|
||
if (option_index == null) | ||
foreach (KeyValuePair<int, OptionDescriptor> option in options) | ||
input_option.Add(options[option.Key]); | ||
else | ||
foreach (int index in option_index) | ||
input_option.Add(options[index]); | ||
return input_option; | ||
} | ||
|
||
protected internal virtual IList<InputProgram> CollectPrograms(IList<int> program_index) | ||
{ | ||
IList<InputProgram> input_programs = new List<InputProgram>(); | ||
|
||
if (program_index == null) | ||
foreach (KeyValuePair<int, InputProgram> program in programs) | ||
input_programs.Add(programs[program.Key]); | ||
else | ||
foreach (int index in program_index) | ||
input_programs.Add(programs[index]); | ||
return input_programs; | ||
} | ||
|
||
public virtual InputProgram GetInputProgram(int key) => programs[key]; | ||
|
||
public virtual OptionDescriptor GetOptionDescriptor(int key) => options[key]; | ||
|
||
public virtual void RemoveAll() | ||
{ | ||
programs.Clear(); | ||
options.Clear(); | ||
} | ||
|
||
public virtual void RemoveOption(int option_id) => options.Remove(option_id); | ||
|
||
public virtual bool RemoveOption(OptionDescriptor o) | ||
{ | ||
bool result = false; | ||
foreach (KeyValuePair<int, OptionDescriptor> entry in options) | ||
if (entry.Value.Equals(o)) | ||
{ | ||
options.Remove(entry.Key); | ||
result = true; | ||
} | ||
return result; | ||
} | ||
|
||
public virtual bool RemoveProgram(InputProgram p) | ||
{ | ||
bool result = false; | ||
foreach (KeyValuePair<int, InputProgram> entry in programs) | ||
if (entry.Value.Equals(p)) | ||
{ | ||
programs.Remove(entry.Key); | ||
result = true; | ||
} | ||
return result; | ||
} | ||
|
||
public virtual void RemoveProgram(int program_id) => programs.Remove(program_id); | ||
|
||
public virtual void StartAsync(ICallback c) => StartAsync(c, (IList<int>)null, (IList<int>)null); | ||
|
||
public virtual void StartAsync(ICallback c, IList<int> program_index, IList<int> option_index) { } | ||
|
||
public virtual Output StartSync() => StartSync((IList<int>)null, (IList<int>)null); | ||
|
||
public virtual Output StartSync(IList<int> program_index, IList<int> option_index) => null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace it.unical.mat.embasp.@base | ||
{ | ||
public class InputProgram | ||
{ | ||
protected internal string programs; | ||
private IList<string> files_paths; | ||
protected internal string separator; | ||
|
||
public InputProgram() | ||
{ | ||
Init(); | ||
separator = " "; | ||
} | ||
|
||
public InputProgram(object inputObj) | ||
{ | ||
Init(); | ||
AddObjectInput(inputObj); | ||
} | ||
|
||
public InputProgram(string initial_program) | ||
{ | ||
Init(); | ||
programs = initial_program; | ||
} | ||
|
||
public virtual void AddFilesPath(string file_path) => files_paths.Add(file_path); | ||
|
||
public virtual void AddObjectInput(object inputObj) => throw new System.NotSupportedException("functionality not implemented"); | ||
|
||
public virtual void AddObjectsInput(ISet<object> inputObjs) | ||
{ | ||
foreach (Object inputObj in inputObjs) | ||
AddObjectInput(inputObj); | ||
} | ||
|
||
public virtual void AddProgram(string new_instruction) | ||
{ | ||
if (programs.Length == 0) | ||
programs = new_instruction; | ||
else | ||
programs += separator + new_instruction; | ||
} | ||
|
||
public virtual void ClearAll() | ||
{ | ||
ClearFilesPaths(); | ||
ClearPrograms(); | ||
} | ||
|
||
public virtual void ClearFilesPaths() => files_paths.Clear(); | ||
|
||
public virtual void ClearPrograms() => programs = ""; | ||
|
||
public virtual IList<string> FilesPaths => files_paths; | ||
|
||
public virtual string Programs { get => programs; set => this.programs = value; } | ||
|
||
public virtual string Separator { get => separator; set => this.separator = value; } | ||
|
||
public virtual string StringOfFilesPaths | ||
{ | ||
get | ||
{ | ||
StringBuilder to_return = new StringBuilder(); | ||
foreach (String paths in files_paths) | ||
if (paths.Length != 0) | ||
to_return.Append(paths).Append(" "); | ||
return to_return.ToString(); | ||
} | ||
} | ||
|
||
private void Init() | ||
{ | ||
programs = ""; | ||
files_paths = new List<string>(); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
CSharp version/it/unical/mat/embasp/base/OptionDescriptor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
namespace it.unical.mat.embasp.@base | ||
{ | ||
public class OptionDescriptor | ||
{ | ||
protected internal string separator; | ||
protected internal string options; | ||
|
||
public OptionDescriptor() | ||
{ | ||
options = ""; | ||
separator = ""; | ||
} | ||
|
||
public OptionDescriptor(string initial_option) : this() | ||
{ | ||
options = initial_option; | ||
} | ||
|
||
public virtual void AddOption(string option) | ||
{ | ||
if (option.Length == 0) | ||
options = option; | ||
else | ||
options += separator + option; | ||
} | ||
|
||
public virtual void Clear() => options = ""; | ||
|
||
public virtual string Options { get => options; set => options = value; } | ||
|
||
public virtual string Separator { get => separator; set => this.separator = value; } | ||
} | ||
} |
Oops, something went wrong.