dlvhex  2.5.0
AggregatePlugin Class Reference

Implements aggregate functions both by native handling or by rewriting them to external atoms. More...

#include <include/dlvhex2/AggregatePlugin.h>

Inheritance diagram for AggregatePlugin:
Collaboration diagram for AggregatePlugin:

Data Structures

class  CtxData

Public Member Functions

 AggregatePlugin ()
 Constructor.
virtual ~AggregatePlugin ()
 Destructor.
virtual void printUsage (std::ostream &o) const
 Output help message for this plugin.
virtual void processOptions (std::list< const char * > &pluginOptions, ProgramCtx &)
 Processes options for this plugin.
virtual PluginRewriterPtr createRewriter (ProgramCtx &)
 Rewriter for hex-programs.
virtual void setupProgramCtx (ProgramCtx &)
 Altering the ProgramCtx permits plugins to do many things, e.g., * installing model and finish callbacks * removing default model (and final) hooks * setting maxint * changing and configuring the solver backend to be used See internal plugins for example usage.
virtual std::vector
< PluginAtomPtr
createAtoms (ProgramCtx &) const
 Publish external computation sources to dlvhex.

Detailed Description

Implements aggregate functions both by native handling or by rewriting them to external atoms.

Definition at line 43 of file AggregatePlugin.h.


Constructor & Destructor Documentation

Constructor.

Definition at line 64 of file AggregatePlugin.cpp.

References PluginInterface::setNameVersion().

Destructor.

Definition at line 71 of file AggregatePlugin.cpp.


Member Function Documentation

std::vector< PluginAtomPtr > AggregatePlugin::createAtoms ( ProgramCtx ctx) const [virtual]

Publish external computation sources to dlvhex.

This is the central location where the user's atoms are made public. dlvhex will call this function for all found plugins, which write their atoms in the provided map. This map associates strings with pointers to PluginAtom objects. The strings denote the name of the atom as it should be used in the program.

Override this method to publish your atoms.

Example:

   std::vector<PluginAtomPtr>
   createAtoms(ProgramCtx& ctx) const
   {
    std::vector<PluginAtomPtr> ret;
      PluginAtomPtr newatom1(new MyAtom1);
      PluginAtomPtr newatom2(new MyAtom2);
      ret["newatom1"] = newatom1;
      ret["newatom2"] = newatom2;
      return ret;
   }

Here, we assume to have defined atoms MyAtom1 and MyAtom2 derived from PluginAtom. These atom can now be used in a HEX-program with the predicate &newatom1[]() and &newatom2[]().

Reimplemented from PluginInterface.

Definition at line 1159 of file AggregatePlugin.cpp.

References DBGLOG, and ProgramCtx::getPluginData().

Rewriter for hex-programs.

The rewriters are called on the parsed HEX program (which may have been rewritten by a PluginConverter). Hence, a rewriter can expect a well-formed HEX-program represented in ProgramCtx::edb and ProgramCtx::idb as input and must of course also take care of keeping that representation correct program.

Reimplemented from PluginInterface.

Definition at line 733 of file AggregatePlugin.cpp.

References ProgramCtx::getPluginData().

void AggregatePlugin::printUsage ( std::ostream &  o) const [virtual]

Output help message for this plugin.

Reimplemented from PluginInterface.

Definition at line 77 of file AggregatePlugin.cpp.

void AggregatePlugin::processOptions ( std::list< const char * > &  pluginOptions,
ProgramCtx ctx 
) [virtual]

Processes options for this plugin.

If you override this method, remove all options your plugin recognizes from pluginOptions. (Do not free the pointers, the const char* directly come from argv.) You can store configuration of your plugin using PluginData and ProgramCtx::getPluginData (see there for more information.)

Reimplemented from PluginInterface.

Definition at line 108 of file AggregatePlugin.cpp.

References ProgramCtx::config, DBGLOG, AggregatePlugin::CtxData::enabled, AggregatePlugin::CtxData::ExtBlRewrite, AggregatePlugin::CtxData::ExtRewrite, ProgramCtx::getPluginData(), AggregatePlugin::CtxData::mode, Configuration::setOption(), AggregatePlugin::CtxData::Simplify, and WARNING().

Altering the ProgramCtx permits plugins to do many things, e.g., * installing model and finish callbacks * removing default model (and final) hooks * setting maxint * changing and configuring the solver backend to be used See internal plugins for example usage.

Reimplemented from PluginInterface.

Definition at line 745 of file AggregatePlugin.cpp.

References AggregatePlugin::CtxData::enabled, ProgramCtx::getPluginData(), and ProgramCtx::registry().


The documentation for this class was generated from the following files: