Merge pull request #62 from BenceJanosSzabo/master
[deliverable/titan.core.git] / core / LoggerPlugin_static.cc
CommitLineData
d44e3c4f 1/******************************************************************************
2 * Copyright (c) 2000-2016 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Balasko, Jeno
10 * Raduly, Csaba
11 *
12 ******************************************************************************/
970ed795
EL
13#include "LoggerPlugin.hh"
14#include "ILoggerPlugin.hh"
15
16#include <assert.h>
17#include <dlfcn.h>
18
19void LoggerPlugin::load()
20{
21 if (this->filename_) {
22 // Dynamic plug-in requires dynamic runtime. Panic.
23 TTCN_Logger::fatal_error("Static runtime cannot load plugins");
24 } else {
25 // Static plug-in. We simply instantiate the class without any `dl*()'.
26 assert(this->create_);
27 this->ref_ = this->create_();
28 }
29
30 this->ref_->init();
31 this->is_log2str_capable_ = this->ref_->is_log2str_capable();
32}
33
34// Completely destroy the logger plug-in and make it useless. However,
35// reloading is possible. This should be called before the logger is
36// deleted.
37void LoggerPlugin::unload()
38{
39 if (!this->ref_) return;
40 this->ref_->fini();
41 if (this->filename_) {
42 // This cannot happen.
43 TTCN_Logger::fatal_error("Static runtime cannot have plugins");
44 } else {
45 // For static plug-ins, it's simple.
46 delete this->ref_;
47 this->create_ = NULL;
48 }
49 this->ref_ = NULL;
50}
This page took 0.025108 seconds and 5 git commands to generate.