Fawkes API Fawkes Development Version
asp.cpp
1
2/***************************************************************************
3 * asp.cpp - ASP aspect for Fawkes
4 *
5 * Created: Thu Oct 20 15:49:31 2016
6 * Copyright 2016 Björn Schäpers
7 * 2018 Tim Niemueller [www.niemueller.org]
8 ****************************************************************************/
9
10/* This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. A runtime exception applies to
14 * this software (see LICENSE.GPL_WRE file mentioned below for details).
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Library General Public License for more details.
20 *
21 * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22 */
23
24#include <plugins/asp/aspect/asp.h>
25#include <plugins/asp/aspect/clingo_access.h>
26
27namespace fawkes {
28
29/** @class ASPAspect <plugins/asp/aspect/asp.h>
30 * Thread aspect to get access to an ASP solver.
31 * Give this aspect to your thread to get a Clingo Control for exclusive usage.
32 *
33 * @ingroup Aspects
34 * @author Björn Schäpers
35 *
36 * @property ASPAspect::control_name_
37 * @brief The name for the control in the manager.
38 *
39 * @property ASPAspect::log_comp_
40 * @brief The component for the logger.
41 *
42 * @property ASPAspect::clingo
43 * @brief Clingo Control for exclusive usage.
44 */
45
46/** Constructor.
47 * @param[in] control_name The desired control name.
48 * @param[in] log_component The component for the logger.
49 */
50ASPAspect::ASPAspect(const std::string &&control_name, const std::string &&log_component)
51: control_name_(std::move(control_name)), log_comp_(std::move(log_component))
52{
53 add_aspect("ASPAspect");
54}
55
56/** Virtual empty destructor. */
58{
59}
60
61/** Init ASP aspect.
62 * This sets the Clingo Control.
63 * It is guaranteed that this is called for an ASP Thread before start is called (when running regularly inside Fawkes).
64 * @param[in] clingo The Clingo Control.
65 */
66void
67ASPAspect::init_ASPAspect(const LockPtr<ClingoAccess> &clingo)
68{
69 this->clingo = clingo;
70}
71
72/** Finalize ASP aspect.
73 * This clears the Clingo Control.
74 */
75void
76ASPAspect::finalize_ASPAspect(void)
77{
78 clingo.clear();
79}
80
81} // end namespace fawkes
virtual ~ASPAspect(void)
Virtual empty destructor.
Definition: asp.cpp:57
LockPtr< ClingoAccess > clingo
Clingo Control for exclusive usage.
Definition: asp.h:50
ASPAspect(const std::string &&control_name, const std::string &&log_component=std::string())
Constructor.
Definition: asp.cpp:50
void add_aspect(const char *name)
Add an aspect to a thread.
Definition: aspect.cpp:49
LockPtr<> is a reference-counting shared lockable smartpointer.
Definition: lockptr.h:55
Fawkes library namespace.