LibreOffice Module basegfx (master) 1
systemdependentdata.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10#pragma once
11
12#include <sal/types.h>
14#include <memory>
15#include <map>
16
17namespace basegfx
18{
19 class SystemDependentData;
20 typedef std::shared_ptr<SystemDependentData> SystemDependentData_SharedPtr;
21 typedef std::weak_ptr<SystemDependentData> SystemDependentData_WeakPtr;
22
24 {
25 private:
26 // noncopyable
29
30 public:
33
34 // call from (and with) SystemDependentData objects when start/end/touch
35 // usage is needed
39
40 // flush all buffered data (e.g. cleanup/shutdown)
41 virtual void flushAll() = 0;
42 };
43
45 {
46 private:
47 // noncopyable
50
51 // reference to a SystemDependentDataManager, probably
52 // a single, globally used one, but not necessarily
54
55 // Buffered CalculatedCycles, result of estimations using
56 // getHoldCyclesInSeconds and estimateUsageInBytes, executed
57 // using getHoldCyclesInSeconds. StartValue is 0 to detect
58 // not-yet-calculated state
60
61 public:
63 SystemDependentDataManager& rSystemDependentDataManager);
64
65 // CAUTION! It is VERY important to keep this base class
66 // virtual, else typeid(class).hash_code() from derived classes
67 // will NOT work what is ESSENTIAL for the SystemDependentData
68 // mechanism to work properly. So DO NOT REMOVE virtual here, please.
69 virtual ~SystemDependentData();
70
71 // allow access to call startUsage/endUsage/touchUsage
72 // using getSystemDependentDataManager()
73 SystemDependentDataManager& getSystemDependentDataManager() { return mrSystemDependentDataManager; }
74
75 // Calculate HoldCyclesInSeconds based on using
76 // getHoldCyclesInSeconds and estimateUsageInBytes, the
77 // result is created once on-demand and buffered in
78 // mnCalculatedCycles
79 sal_uInt32 calculateCombinedHoldCyclesInSeconds() const;
80
81 // Allow read access to the calculated cycles in seconds, this
82 // can be e.g. used to determine if this instance got added
83 sal_uInt32 getCombinedHoldCyclesInSeconds() const { return mnCalculatedCycles; }
84
85 // Size estimation of the entry in bytes - does not have to
86 // be used, but should be. Default returns zero what
87 // means there is no size estimation available. Override to
88 // offer useful data if you want to have better caching.
89 virtual sal_Int64 estimateUsageInBytes() const;
90 };
91
93 {
94 private:
95 // Possibility to hold System-Dependent B2DPolygon-Representations
96 std::map< size_t, SystemDependentData_WeakPtr > maSystemDependentReferences;
97
98 // noncopyable
101
102 public:
105
106 void addOrReplaceSystemDependentData(SystemDependentData_SharedPtr& rData);
107 SystemDependentData_SharedPtr getSystemDependentData(size_t hash_code) const;
108 };
109} // end of namespace basegfx
110
111/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define BASEGFX_DLLPUBLIC
Definition: basegfxdllapi.h:35
SystemDependentDataHolder(const SystemDependentDataHolder &)=delete
SystemDependentDataHolder & operator=(const SystemDependentDataHolder &)=delete
std::map< size_t, SystemDependentData_WeakPtr > maSystemDependentReferences
virtual void endUsage(basegfx::SystemDependentData_SharedPtr &rData)=0
virtual void startUsage(basegfx::SystemDependentData_SharedPtr &rData)=0
virtual void touchUsage(basegfx::SystemDependentData_SharedPtr &rData)=0
SystemDependentDataManager & operator=(const SystemDependentDataManager &)=delete
SystemDependentDataManager(const SystemDependentDataManager &)=delete
SystemDependentDataManager & getSystemDependentDataManager()
SystemDependentData(const SystemDependentData &)=delete
SystemDependentDataManager & mrSystemDependentDataManager
SystemDependentData & operator=(const SystemDependentData &)=delete
sal_uInt32 getCombinedHoldCyclesInSeconds() const
std::shared_ptr< SystemDependentData > SystemDependentData_SharedPtr
Definition: b2dpolygon.hxx:41
std::weak_ptr< SystemDependentData > SystemDependentData_WeakPtr