Fawkes API Fawkes Development Version
clingo_manager_inifin.cpp
1/***************************************************************************
2 * clingo_manager_inifin.cpp - Fawkes ClingoManagerAspect initializer/finalizer
3 *
4 * Created: Sat Oct 29 11:30:07 2016
5 * Copyright 2016 Björn Schäpers
6 * 2018 Tim Niemueller [www.niemueller.org]
7 ****************************************************************************/
8
9/* This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version. A runtime exception applies to
13 * this software (see LICENSE.GPL_WRE file mentioned below for details).
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Library General Public License for more details.
19 *
20 * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
21 */
22
23#include <plugins/asp/aspect/clingo_manager.h>
24#include <plugins/asp/aspect/clingo_manager_inifin.h>
25
26namespace fawkes {
27
28/**
29 * @class ClingoManagerAspectIniFin <plugins/asp/aspect/clingo_manager_inifin.h>
30 * ClingoManagerAspect initializer/finalizer.
31 * @author Björn Schäpers
32 *
33 * @property ClingoManagerAspectIniFin::clingo_ctrl_mgr_
34 * @brief The Clingo control manager.
35 */
36
37/** Constructor. */
39{
40}
41
42/** Destructor. */
44{
45}
46
47void
49{
50 auto clingo_thread = dynamic_cast<ClingoManagerAspect *>(thread);
51 if (clingo_thread == nullptr) {
52 throw CannotInitializeThreadException("Thread '%s' claims to have the ClingoManagerAspect, "
53 "but RTTI says it has not. ",
54 thread->name());
55 }
56
57 clingo_thread->init_ClingoManagerAspect(clingo_ctrl_mgr_);
58}
59
60void
62{
63 auto clingo_thread = dynamic_cast<ClingoManagerAspect *>(thread);
64 if (clingo_thread == nullptr) {
65 throw CannotFinalizeThreadException("Thread '%s' claims to have the ClingoManagerAspect, "
66 "but RTTI says it has not. ",
67 thread->name());
68 }
69
70 clingo_thread->finalize_ClingoManagerAspect();
71}
72
73/** Set Clingo control manger.
74 * @param[in] clingo_ctrl_mgr Clingo control manager
75 */
76void
78{
79 clingo_ctrl_mgr_ = clingo_ctrl_mgr;
80}
81
82} // end namespace fawkes
Aspect initializer/finalizer base class.
Definition: inifin.h:34
Thread cannot be finalized.
void init(Thread *thread) override
Initialize thread.
void set_control_manager(LockPtr< ClingoControlManager > &clingo_ctrl_mgr)
Set Clingo control manger.
void finalize(Thread *thread) override
Finalize thread.
Thread aspect to access the Clingo Control manager.
LockPtr<> is a reference-counting shared lockable smartpointer.
Definition: lockptr.h:55
Thread class encapsulation of pthreads.
Definition: thread.h:46
const char * name() const
Get name of thread.
Definition: thread.h:100
Fawkes library namespace.