2 * Copyright (C) 2014 - Christian Babeux <christian.babeux@efficios.com>
5 * This library is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU Lesser General Public License, version 2.1 only,
7 * as published by the Free Software Foundation.
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 package org
.lttng
.ust
.agent
;
22 import java
.util
.HashMap
;
23 import java
.util
.Iterator
;
25 public abstract class LogFrameworkSkeleton
implements LogFramework
{
27 /* A map of event name and reference count */
28 private Map
<String
, Integer
> enabledLoggers
;
30 public LogFrameworkSkeleton() {
31 this.enabledLoggers
= new HashMap
<String
, Integer
>();
35 public Boolean
enableLogger(String name
) {
40 if (enabledLoggers
.containsKey(name
)) {
41 /* Event is already enabled, simply increment its refcount */
42 Integer refcount
= enabledLoggers
.get(name
);
44 Integer oldval
= enabledLoggers
.put(name
, refcount
);
45 assert (oldval
!= null);
47 /* Event was not enabled, init refcount to 1 */
48 Integer oldval
= enabledLoggers
.put(name
, 1);
49 assert (oldval
== null);
56 public Boolean
disableLogger(String name
) {
61 if (!enabledLoggers
.containsKey(name
)) {
62 /* Event was never enabled, abort */
66 /* Event was previously enabled, simply decrement its refcount */
67 Integer refcount
= enabledLoggers
.get(name
);
69 assert (refcount
>= 0);
72 /* Event is not used anymore, remove it from the map */
73 Integer oldval
= enabledLoggers
.remove(name
);
74 assert (oldval
!= null);
81 public abstract Iterator
<String
> listLoggers();
84 public abstract Boolean
isRoot();
88 enabledLoggers
.clear();
91 protected Integer
getEventCount() {
92 return enabledLoggers
.size();
This page took 0.035158 seconds and 5 git commands to generate.