=================== Narrative implementation =================== The following figure provides some details about classes and interfaces of the implementation. .. raw:: html
Base module implementation ========================== Each component in the :guilabel:`Base` module has been implemented by means of an abstract class, generic class or interface that will specialize in the following packages. In particular, the |Handler|_ class collects |InputProgram|_ and |OptionDescriptor|_ objects communicated by the user. For what the asynchronous mode is concerned, the interface |Service|_ depends from the interface |Callback|_, since once the reasoning service has terminated, the result of the computation is returned back via a class |Callback|_. Platforms module implementation =============================== In order to support a new platform, the |Handler|_ and |Service|_ components must be adapted. As for the Android platform, we developed an |AndroidHandler|_ that handles the execution of an |AndroidService|_, which provides facilities to manage the execution of a solver on the Android platform. Similarly, for the desktop platform we developed a |DesktopHandler|_ and a |DesktopService|_, which generalizes the usage of a solver on the desktop platform, allowing both synchronous and asynchronous execution modes. Languages module implementation =============================== This module includes specific classes for the management of input and output to ASP, Datalog and PDDL solvers. The |Mapper|_ component of the :guilabel:`Languages` module is implemented via a |Mapper|_ class, that allows to translate input and output into Narrative objects. Such translations are guided by `ANTLR4 `_ library and `Narrative Annotations `_ , a form of metadata that mark Narrative code and provide information that is not part of the program itself: they have no direct effect on the operation of the code they annotate. In our setting, we make use of such feature so that it is possible to translate facts into strings and vice-versa via two custom annotations, defined according to the following syntax: * *@Id (string_name)* : the target must be a class, and defines the predicate name (in the ASP/Datalog case) and the action name (in the PDDL case) the class is mapped to; * *@Param (integer_position)* : the target must be a field of a class annotated via *@Id*, and defines the term (and its position) in the atom (in the ASP/Datalog case) and in the action (in the PDDL case) the field is mapped to. By means of the `Narrative Reflection `_ mechanisms, annotations are examined at runtime, and taken into account to properly define the translation. If the classes intended for the translation are not annotated or not correctly annotated, an exception is raised. In addition to the |Mapper|_, this module features three sub-modules which are more strictly related to ASP, PDDL and Datalog. Specialization module Implementation ==================================== The classes |DLVAnswerSets|_, |DLV2AnswerSets|_, |ClingoAnswerSets|_, |DLVHEXAnswerSets|_ implement specific extensions of the |AnswerSets|_ class, the |SPDPlan|_ class extends |Plan|_, while |IDLVMinimalModels|_ extends |MinimalModels|_ . These classes are in charge of manipulating the output of the respective solvers (e.g. IDLV). Moreover, this module can contain classes extending |OptionDescriptor|_ to implement specific options of the solver at hand. Class Diagram ============= A complete UML Class Diagram is available `here <../_static/complete_diagram_narrative.svg>`_. | For further information, contact `embasp@mat.unical.it `_ or visit our `website `_. .. |Handler| replace:: ``Handler`` .. |InputProgram| replace:: ``InputProgram`` .. |OptionDescriptor| replace:: ``OptionDescriptor`` .. |Service| replace:: ``Service`` .. |CallBack| replace:: ``CallBack`` .. |AndroidHandler| replace:: ``AndroidHandler`` .. |AndroidService| replace:: ``AndroidService`` .. |DesktopHandler| replace:: ``DesktopHandler`` .. |DesktopService| replace:: ``DesktopService`` .. |Mapper| replace:: ``Mapper`` .. |DLVAnswerSets| replace:: ``DLVAnswerSets`` .. |DLV2AnswerSets| replace:: ``DLV2AnswerSets`` .. |ClingoAnswerSets| replace:: ``ClingoAnswerSets`` .. |DLVHEXAnswerSets| replace:: ``DLVHEXAnswerSets`` .. |IDLVMinimalModels| replace:: ``IDLVMinimalModels`` .. |MinimalModels| replace:: ``MinimalModels`` .. |SPDPlan| replace:: ``SPDPlan`` .. |AnswerSets| replace:: ``AnswerSets`` .. |Plan| replace:: ``Plan`` .. _Handler: ../_static/doxygen/narrative/classit_1_1unical_1_1mat_1_1embasp_1_1base_1_1Handler.html .. _InputProgram: ../_static/doxygen/narrative/classit_1_1unical_1_1mat_1_1embasp_1_1base_1_1InputProgram.html .. _OptionDescriptor: ../_static/doxygen/narrative/classit_1_1unical_1_1mat_1_1embasp_1_1base_1_1OptionDescriptor.html .. _Service: ../_static/doxygen/narrative/interfaceit_1_1unical_1_1mat_1_1embasp_1_1base_1_1Service.html .. _CallBack: ../_static/doxygen/narrative/interfaceit_1_1unical_1_1mat_1_1embasp_1_1base_1_1Callback.html .. _AndroidHandler: ../_static/doxygen/narrative/classit_1_1unical_1_1mat_1_1embasp_1_1platforms_1_1android_1_1AndroidHandler.html .. _AndroidService: ../_static/doxygen/narrative/classit_1_1unical_1_1mat_1_1embasp_1_1platforms_1_1android_1_1AndroidService.html .. _DesktopHandler: ../_static/doxygen/narrative/classit_1_1unical_1_1mat_1_1embasp_1_1platforms_1_1desktop_1_1DesktopHandler.html .. _DesktopService: ../_static/doxygen/narrative/classit_1_1unical_1_1mat_1_1embasp_1_1platforms_1_1desktop_1_1DesktopService.html .. _Mapper: ../_static/doxygen/narrative/classit_1_1unical_1_1mat_1_1embasp_1_1languages_1_1Mapper.html .. _DLVAnswerSets: ../_static/doxygen/narrative/classit_1_1unical_1_1mat_1_1embasp_1_1specializations_1_1dlv_1_1DLVAnswerSets.html .. _DLV2AnswerSets: ../_static/doxygen/narrative/classit_1_1unical_1_1mat_1_1embasp_1_1specializations_1_1dlv2_1_1DLV2AnswerSets.html .. _ClingoAnswerSets: ../_static/doxygen/narrative/classit_1_1unical_1_1mat_1_1embasp_1_1specializations_1_1clingo_1_1ClingoAnswerSets.html .. _DLVHEXAnswerSets: ../_static/doxygen/narrative/classit_1_1unical_1_1mat_1_1embasp_1_1specializations_1_1dlvhex_1_1DLVHEXAnswerSets.html .. _IDLVMinimalModels: ../_static/doxygen/narrative/classit_1_1unical_1_1mat_1_1embasp_1_1specializations_1_1idlv_1_1IDLVMinimalModels.html .. _SPDPlan: ../_static/doxygen/narrative/classit_1_1unical_1_1mat_1_1embasp_1_1specializations_1_1solver__planning__domains_1_1SPDPlan.html .. _AnswerSets: ../_static/doxygen/narrative/classit_1_1unical_1_1mat_1_1embasp_1_1languages_1_1asp_1_1AnswerSets.html .. _MinimalModels: ../_static/doxygen/narrative/classit_1_1unical_1_1mat_1_1embasp_1_1languages_1_1datalog_1_1MinimalModels.html .. _Plan: ../_static/doxygen/narrative/classit_1_1unical_1_1mat_1_1embasp_1_1languages_1_1pddl_1_1Plan.html