/src/logging-log4cxx/src/main/include/log4cxx/helpers/aprinitializer.h
Line | Count | Source (jump to first uncovered line) |
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 | | #if LOG4CXX_ABI_VERSION <= 15 |
39 | | class FileWatchdog; |
40 | | #endif |
41 | | |
42 | | class APRInitializer |
43 | | { |
44 | | public: |
45 | | #if LOG4CXX_ABI_VERSION <= 15 |
46 | | static log4cxx_time_t initialize(); |
47 | | static bool isDestructed; |
48 | | #endif |
49 | | static apr_pool_t* getRootPool(); |
50 | | static log4cxx_time_t getStartTime(); |
51 | | static apr_threadkey_t* getTlsKey(); |
52 | | |
53 | | #if LOG4CXX_ABI_VERSION <= 15 |
54 | | /** |
55 | | * Register a FileWatchdog for deletion prior to termination. |
56 | | * FileWatchdog must be |
57 | | * allocated on heap and not deleted elsewhere. |
58 | | */ |
59 | | static void registerCleanup(FileWatchdog* watchdog); |
60 | | static void unregisterCleanup(FileWatchdog* watchdog); |
61 | | static void unregisterAll(); |
62 | | #endif |
63 | | /** |
64 | | * Store a single instance type ObjectPtr for deletion prior to termination |
65 | | */ |
66 | | template <class T> static void setUnique(const std::shared_ptr<T>& pObject) |
67 | 0 | { |
68 | 0 | getInstance().addObject(typeid(T).hash_code(), pObject); |
69 | 0 | } |
70 | | /** |
71 | | * Fetch or add a single instance type ObjectPtr for deletion prior to termination |
72 | | */ |
73 | | template <class T> static std::shared_ptr<T> getOrAddUnique(std::function<ObjectPtr()> creator) |
74 | 14.8k | { |
75 | 14.8k | return cast<T>(getInstance().findOrAddObject(typeid(T).hash_code(), creator)); |
76 | 14.8k | } std::__1::shared_ptr<log4cxx::spi::RepositorySelector> log4cxx::helpers::APRInitializer::getOrAddUnique<log4cxx::spi::RepositorySelector>(std::__1::function<std::__1::shared_ptr<log4cxx::helpers::Object> ()>) Line | Count | Source | 74 | 7.87k | { | 75 | 7.87k | return cast<T>(getInstance().findOrAddObject(typeid(T).hash_code(), creator)); | 76 | 7.87k | } |
Unexecuted instantiation: std::__1::shared_ptr<log4cxx::helpers::SingletonHolder<log4cxx::ConfiguratorWatchdog> > log4cxx::helpers::APRInitializer::getOrAddUnique<log4cxx::helpers::SingletonHolder<log4cxx::ConfiguratorWatchdog> >(std::__1::function<std::__1::shared_ptr<log4cxx::helpers::Object> ()>) Unexecuted instantiation: std::__1::shared_ptr<log4cxx::helpers::SingletonHolder<log4cxx::PropertyWatchdog> > log4cxx::helpers::APRInitializer::getOrAddUnique<log4cxx::helpers::SingletonHolder<log4cxx::PropertyWatchdog> >(std::__1::function<std::__1::shared_ptr<log4cxx::helpers::Object> ()>) std::__1::shared_ptr<log4cxx::helpers::SingletonHolder<log4cxx::helpers::ThreadUtility> > log4cxx::helpers::APRInitializer::getOrAddUnique<log4cxx::helpers::SingletonHolder<log4cxx::helpers::ThreadUtility> >(std::__1::function<std::__1::shared_ptr<log4cxx::helpers::Object> ()>) Line | Count | Source | 74 | 1.62k | { | 75 | 1.62k | return cast<T>(getInstance().findOrAddObject(typeid(T).hash_code(), creator)); | 76 | 1.62k | } |
Unexecuted instantiation: std::__1::shared_ptr<log4cxx::helpers::SingletonHolder<log4cxx::xml::XMLWatchdog> > log4cxx::helpers::APRInitializer::getOrAddUnique<log4cxx::helpers::SingletonHolder<log4cxx::xml::XMLWatchdog> >(std::__1::function<std::__1::shared_ptr<log4cxx::helpers::Object> ()>) configurator.cpp:std::__1::shared_ptr<log4cxx::helpers::SingletonHolder<std::__1::pair<(anonymous namespace)::ConfiguratorTag, log4cxx::helpers::Properties> > > log4cxx::helpers::APRInitializer::getOrAddUnique<log4cxx::helpers::SingletonHolder<std::__1::pair<(anonymous namespace)::ConfiguratorTag, log4cxx::helpers::Properties> > >(std::__1::function<std::__1::shared_ptr<log4cxx::helpers::Object> ()>) Line | Count | Source | 74 | 5.34k | { | 75 | 5.34k | return cast<T>(getInstance().findOrAddObject(typeid(T).hash_code(), creator)); | 76 | 5.34k | } |
|
77 | | |
78 | | |
79 | | private: // Constructors |
80 | | friend class helpers::WideLife<APRInitializer>; |
81 | | APRInitializer(); |
82 | | APRInitializer(const APRInitializer&) = delete; |
83 | | APRInitializer& operator=(const APRInitializer&) = delete; |
84 | | private: // Modifiers |
85 | | void addObject(size_t key, const ObjectPtr& pObject); |
86 | | const ObjectPtr& findOrAddObject(size_t key, std::function<ObjectPtr()> creator); |
87 | | private: // Attributes |
88 | | LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(APRInitializerPrivate, m_priv) |
89 | | private: // Class methods |
90 | | static APRInitializer& getInstance(); |
91 | | |
92 | | public: // Destructor |
93 | | ~APRInitializer(); |
94 | | }; |
95 | | } // namespace helpers |
96 | | } // namespace log4cxx |
97 | | |
98 | | #endif //_LOG4CXX_HELPERS_APRINITIALIZER_H |