Line data Source code
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 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef ARY_TYPES_HXX
21 : #define ARY_TYPES_HXX
22 :
23 : // USED SERVICES
24 : // BASE CLASSES
25 : // OTHER
26 :
27 :
28 : namespace ary
29 : {
30 :
31 :
32 : typedef uintt Rid;
33 : typedef uintt ClassId;
34 :
35 :
36 :
37 : // Deprecated:
38 : typedef Rid Gid; /// Group Id. Id of a group.
39 : typedef UINT8 SlotAccessId; /// Access to a Slot
40 : typedef std::set< Rid, std::less< Rid > > Set_Rid;
41 : typedef std::vector<Rid> List_Rid;
42 :
43 :
44 :
45 :
46 :
47 : /** This is a global id, providing as well an entity's class as its
48 : id.
49 : */
50 : class GlobalId
51 : {
52 : public:
53 : GlobalId()
54 : : nClass(0),
55 : nId(0) {}
56 : GlobalId(
57 : ClassId i_class,
58 : Rid i_id )
59 : : nClass(i_class),
60 : nId(i_id) {}
61 : ~GlobalId() {}
62 :
63 : bool IsValid() const { return nClass != 0
64 : AND
65 : nId != 0; }
66 : ClassId Class() const { return nClass; }
67 : Rid Id() const { return nId; }
68 :
69 : private:
70 : // DATA
71 : ClassId nClass;
72 : Rid nId;
73 : };
74 :
75 :
76 : typedef std::vector<GlobalId> List_GlobalIds;
77 :
78 :
79 : /** This is a typed repository id. It allows to get
80 : an object of a specific type.
81 : */
82 : template <class IFC>
83 : class TypedId
84 : {
85 : public:
86 : typedef TypedId<IFC> self;
87 :
88 :
89 449782 : explicit TypedId(
90 : Rid i_nId = 0 )
91 449782 : : nId(i_nId) {}
92 94407 : TypedId<IFC> & operator=(
93 : Rid i_nId )
94 94407 : { nId = i_nId; return *this; }
95 5483122 : bool operator==(
96 : const TypedId<IFC> &
97 : i_nId ) const
98 5483122 : { return nId == i_nId.nId; }
99 127 : bool operator!=(
100 : const TypedId<IFC> &
101 : i_nId ) const
102 127 : { return NOT operator==(i_nId); }
103 96524 : bool operator<(
104 : const TypedId<IFC> &
105 : i_nId ) const
106 96524 : { return nId < i_nId.nId; }
107 :
108 795000 : bool IsValid() const { return nId != 0; }
109 1685704 : Rid Value() const { return nId; }
110 :
111 378 : static self Null_() { return self(0); }
112 :
113 : private:
114 : // DATA
115 : Rid nId;
116 : };
117 :
118 :
119 :
120 :
121 : } // namespace ary
122 : #endif
123 :
124 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|