xref: /aoo4110/main/autodoc/inc/ary/types.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef ARY_TYPES_HXX
25 #define ARY_TYPES_HXX
26 
27 // USED SERVICES
28     // BASE CLASSES
29     // OTHER
30 
31 
32 namespace ary
33 {
34 
35 
36 typedef uintt           Rid;
37 typedef uintt           ClassId;
38 
39 
40 
41 // Deprecated:
42 typedef Rid             Gid;        /// Group Id. Id of a group.
43 typedef UINT8           SlotAccessId;   /// Access to a Slot
44 typedef std::set< Rid, std::less< Rid > >   Set_Rid;
45 typedef std::vector<Rid>	                List_Rid;
46 
47 
48 
49 
50 
51 /** This is a global id, providing as well an entity's class as its
52     id.
53 */
54 class GlobalId
55 {
56   public:
GlobalId()57                         GlobalId()
58                             :   nClass(0),
59                                 nId(0) {}
GlobalId(ClassId i_class,Rid i_id)60                         GlobalId(
61                             ClassId             i_class,
62                             Rid                 i_id )
63                             :   nClass(i_class),
64                                 nId(i_id) {}
~GlobalId()65                         ~GlobalId() {}
66 
IsValid() const67     bool                IsValid() const         { return nClass != 0
68                                                   AND
69                                                   nId != 0; }
Class() const70     ClassId             Class() const           { return nClass; }
Id() const71     Rid                 Id() const              { return nId; }
72 
73   private:
74     // DATA
75     ClassId             nClass;
76     Rid                 nId;
77 };
78 
79 
80 typedef std::vector<GlobalId>   List_GlobalIds;
81 
82 
83 /** This is a typed repository id. It allows to get
84     an object of a specific type.
85 */
86 template <class IFC>
87 class TypedId
88 {
89   public:
90     typedef TypedId<IFC>                        self;
91 
92 
TypedId(Rid i_nId=0)93     explicit            TypedId(
94                             Rid                 i_nId = 0 )
95                                                 : nId(i_nId) {}
operator =(Rid i_nId)96     TypedId<IFC> &      operator=(
97                             Rid                 i_nId )
98                                                 { nId = i_nId; return *this; }
operator ==(const TypedId<IFC> & i_nId) const99     bool                operator==(
100                             const TypedId<IFC> &
101                                                 i_nId ) const
102                                                 { return nId == i_nId.nId; }
operator !=(const TypedId<IFC> & i_nId) const103     bool                operator!=(
104                             const TypedId<IFC> &
105                                                 i_nId ) const
106                                                 { return NOT operator==(i_nId); }
operator <(const TypedId<IFC> & i_nId) const107     bool                operator<(
108                             const TypedId<IFC> &
109                                                 i_nId ) const
110                                                 { return nId < i_nId.nId; }
111 
IsValid() const112     bool                IsValid() const         { return nId != 0; }
Value() const113     Rid                 Value() const           { return nId; }
114 
Null_()115     static self         Null_()                 { return self(0); }
116 
117   private:
118     // DATA
119     Rid                 nId;
120 };
121 
122 
123 
124 
125 }   // namespace ary
126 #endif
127