Apache Log4cxx
Version 2.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
aprinitializer.h
Go to the documentation of this file.
1
/*
2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*/
17
18
#ifndef _LOG4CXX_HELPERS_APRINITIALIZER_H
19
#define _LOG4CXX_HELPERS_APRINITIALIZER_H
20
21
#ifndef LOG4CXX
22
#error "aprinitializer.h should only be included by log4cxx implementation"
23
#endif
24
25
#include <
log4cxx/helpers/object.h
>
26
#include <
log4cxx/helpers/widelife.h
>
27
28
extern
"C"
{
29
struct
apr_threadkey_t;
30
struct
apr_pool_t;
31
}
32
#include <functional>
33
34
namespace
LOG4CXX_NS
35
{
36
namespace
helpers
37
{
38
39
class
APRInitializer
40
{
41
public
:
42
static
apr_pool_t*
getRootPool
();
43
static
log4cxx_time_t
getStartTime
();
44
static
apr_threadkey_t*
getTlsKey
();
45
49
template
<
class
T>
static
void
setUnique
(
const
std::shared_ptr<T>& pObject)
50
{
51
getInstance().addObject(
typeid
(T).hash_code(), pObject);
52
}
53
56
template
<
class
T>
static
std::shared_ptr<T>
getOrAddUnique
(std::function<ObjectPtr()> creator)
57
{
58
return
cast<T>
(getInstance().findOrAddObject(
typeid
(T).hash_code(), creator));
59
}
60
61
62
private
:
// Constructors
63
friend
class
helpers::WideLife
<
APRInitializer
>;
64
APRInitializer
();
65
APRInitializer
(
const
APRInitializer
&) =
delete
;
66
APRInitializer
& operator=(
const
APRInitializer
&) =
delete
;
67
private
:
// Modifiers
68
void
addObject(
size_t
key,
const
ObjectPtr& pObject);
69
const
ObjectPtr findOrAddObject(
size_t
key, std::function<ObjectPtr()> creator);
70
private
:
// Attributes
71
LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(APRInitializerPrivate, m_priv)
72
private
:
// Class methods
73
static
APRInitializer
& getInstance();
74
75
public
:
// Destructor
76
~APRInitializer
();
77
};
78
}
// namespace helpers
79
}
// namespace log4cxx
80
81
#endif
//_LOG4CXX_HELPERS_APRINITIALIZER_H
log4cxx::helpers::APRInitializer
Definition
aprinitializer.h:40
log4cxx::helpers::APRInitializer::~APRInitializer
~APRInitializer()
log4cxx::helpers::APRInitializer::getTlsKey
static apr_threadkey_t * getTlsKey()
log4cxx::helpers::APRInitializer::getOrAddUnique
static std::shared_ptr< T > getOrAddUnique(std::function< ObjectPtr()> creator)
Fetch or add a single instance type ObjectPtr for deletion prior to termination.
Definition
aprinitializer.h:56
log4cxx::helpers::APRInitializer::getStartTime
static log4cxx_time_t getStartTime()
log4cxx::helpers::APRInitializer::getRootPool
static apr_pool_t * getRootPool()
log4cxx::helpers::APRInitializer::setUnique
static void setUnique(const std::shared_ptr< T > &pObject)
Store a single instance type ObjectPtr for deletion prior to termination.
Definition
aprinitializer.h:49
log4cxx::helpers::WideLife
The WideLife wrapper is destined to prolongate the runtime logger state lifetime from static duration...
Definition
widelife.h:37
log4cxx::cast
std::shared_ptr< Ret > cast(const std::shared_ptr< Type > &incoming)
Attempt to cast one Object to another kind of Object.
Definition
object.h:123
object.h
widelife.h
src
main
include
log4cxx
helpers
aprinitializer.h
Generated by
1.18.0 on
SITE_PUBLISHED_DATE
Copyright © 2017-2026
Apache Software Foundation
. Apache, Chainsaw, log4cxx, Log4j, Log4net, log4php and the Apache logo are
trademarks or registered trademarks
of The Apache Software Foundation.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
Privacy Policy
.