Aspose.Tasks for C++
Key.h
1 #pragma once
2 //-----------------------------------------------------------------------
3 // <copyright file="Key.cs" company="Aspose Pty Ltd">
4 // Copyright (c) 2002-2024 Aspose Pty Ltd. All Rights Reserved.
5 // </copyright>
6 //-----------------------------------------------------------------------
7 
8 #include <system/type_info.h>
9 #include <system/object_ext.h>
10 #include <system/details/pointer_collection_helpers.h>
11 #include <system/constraints.h>
12 #include <cstdint>
13 
14 namespace Aspose
15 {
16 namespace Tasks
17 {
18 class Asn;
19 namespace Connectivity
20 {
21 class MspAssn;
22 class MspAssnBaseLine;
23 class MspCal;
24 class MspExtAttr;
25 class MspTsk;
26 class MspTskBaseLine;
27 class MspTskLink;
28 class PmCal;
29 class PmCurr;
30 class PmRsc;
31 class PmRscRate;
32 class PmTaskLink;
33 } // namespace Connectivity
34 namespace IO
35 {
36 namespace MSProject
37 {
38 template <typename, typename> class FieldItem;
39 } // namespace MSProject
40 namespace Pwa
41 {
42 namespace InternalApi
43 {
44 class InternalApiProjectWriter;
45 namespace Mapping
46 {
47 class ProjectGuidPropertyMapper;
48 } // namespace Mapping
49 } // namespace InternalApi
50 } // namespace Pwa
51 } // namespace IO
52 class Prj;
53 namespace Properties
54 {
55 class BuiltInProjectProperty;
56 } // namespace Properties
57 template <typename> class PropertyContainer;
58 class Rsc;
59 class Task;
60 class Tsk;
61 } // namespace Tasks
62 } // namespace Aspose
63 
64 namespace Aspose {
65 
66 namespace Tasks {
67 
68 /// <summary>
69 /// Represents a property key of a class of the specified type.
70 /// An instance of this class is used when getting or setting property of a container.
71 /// </summary>
72 /// <typeparam name="T">The type of property value.</typeparam>
73 /// <typeparam name="K">The type of property key.</typeparam>
74 template<typename T, typename K>
75 class Key : public System::Object, public System::Details::BoxableObjectBase
76 {
77  assert_is_cs_struct(K);
78 
79  typedef Key<T, K> ThisType;
80  typedef System::Object BaseType;
81 
82  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
83  RTTI_INFO_TEMPLATE_CLASS(ThisType, ThisTypeBaseTypesInfo);
84 
85  friend class Aspose::Tasks::Asn;
86  friend class Aspose::Tasks::Task;
87  friend class Aspose::Tasks::IO::Pwa::InternalApi::Mapping::ProjectGuidPropertyMapper;
89  friend class Aspose::Tasks::IO::Pwa::InternalApi::InternalApiProjectWriter;
90  template<typename FT0> friend class Aspose::Tasks::PropertyContainer;
91  friend class Aspose::Tasks::Connectivity::MspAssn;
92  friend class Aspose::Tasks::Connectivity::MspAssnBaseLine;
93  friend class Aspose::Tasks::Connectivity::MspCal;
94  friend class Aspose::Tasks::Connectivity::MspExtAttr;
95  friend class Aspose::Tasks::Connectivity::MspTsk;
96  friend class Aspose::Tasks::Connectivity::MspTskBaseLine;
97  friend class Aspose::Tasks::Connectivity::MspTskLink;
98  friend class Aspose::Tasks::Connectivity::PmCal;
99  friend class Aspose::Tasks::Connectivity::PmCurr;
100  friend class Aspose::Tasks::Connectivity::PmRsc;
101  friend class Aspose::Tasks::Connectivity::PmRscRate;
102  friend class Aspose::Tasks::Connectivity::PmTaskLink;
103  template<typename FT0, typename FT1> friend class Aspose::Tasks::IO::MSProject::FieldItem;
104  template<typename FT0, typename FT1> friend class Aspose::Tasks::IO::MSProject::FieldItem;
105  friend class Aspose::Tasks::Prj;
106  friend class Aspose::Tasks::Rsc;
107  friend class Aspose::Tasks::Tsk;
108  template<typename FT0, typename FT1> friend class Aspose::Tasks::Key;
109  template<typename FT0, typename FT1> friend
110  bool operator ==(Key<FT0, FT1> k1, Key<FT0, FT1> k2);
111  template<typename FT0, typename FT1> friend
112  bool operator !=(Key<FT0, FT1> k1, Key<FT0, FT1> k2);
113 
114 public:
115 
116  /// <summary>
117  /// Gets the key of the property.
118  /// </summary>
119  K get_KeyType() const
120  {
121  return (*this).keyType;
122  }
123 
124  Key() : keyTypeIndex(0), propCategory(0), keyType(K())
125  {
126  }
127 
128  void SetTemplateWeakPtr(uint32_t argument) override
129  {
130  switch (argument)
131  {
132  case 0:
133  break;
134 
135  case 1:
136  System::Details::CollectionHelpers::SetWeakPointer(keyType);
137  break;
138 
139  }
140  }
141 
142 protected:
143 
144  int32_t get_KeyTypeIndex() const
145  {
146  return (*this).keyTypeIndex;
147  }
148 
149  uint8_t get_PropCategory() const
150  {
151  return (*this).propCategory;
152  }
153 
154  System::String get_KeyName()
155  {
156  return System::ObjectExt::ToString((*this).keyType);
157  }
158 
159  Key(K keyType) : Key(keyType, 0)
160  {
161  }
162 
163  MEMBER_FUNCTION_MAKE_OBJECT(Key, CODEPORTING_ARGS(K keyType), CODEPORTING_ARGS(keyType));
164 
165  Key(K keyType, uint8_t category) : keyTypeIndex(0), propCategory(0), keyType(K())
166  {
167  (*this).keyType = keyType;
168  (*this).propCategory = category;
169  (*this).keyTypeIndex = (uint8_t)keyType;
170  }
171 
172  MEMBER_FUNCTION_MAKE_OBJECT(Key, CODEPORTING_ARGS(K keyType, uint8_t category), CODEPORTING_ARGS(keyType,category));
173  template <typename TC>
174  bool IsEqual(Key<TC, K> key)
175  {
176  return (*this).get_KeyTypeIndex() == key.get_KeyTypeIndex() && System::ObjectExt::GetType<T>() == System::ObjectExt::GetType<TC>();
177  }
178 
179  #ifdef ASPOSE_GET_SHARED_MEMBERS
180  void GetSharedMembers(System::Object::shared_members_type& result) const override
181  {
182  System::Object::GetSharedMembers(result);
183 
184  result.Add("Aspose::Tasks::Key::keyType", this->keyType);
185  }
186  #endif
187 
188 
189 
190 private:
191 
192  uint8_t keyTypeIndex;
193  uint8_t propCategory;
194 
195  static System::TypeInfo& UnderlyingType()
196  {
197  static System::TypeInfo value;
198  static std::once_flag once;
199  std::call_once(once, []
200  {
201  value = System::Enum<K>::GetUnderlyingType();
202  });
203  return value;
204  }
205 
206  K keyType;
207 
208 };
209 
210 template<typename T, typename K>
211 bool operator ==(Key<T, K> k1, Key<T, K> k2)
212 {
213  return System::ObjectExt::Equals(k1.keyType, k2.keyType);
214 }
215 
216 template<typename T, typename K>
217 bool operator !=(Key<T, K> k1, Key<T, K> k2)
218 {
219  return !System::ObjectExt::Equals(k1.keyType, k2.keyType);
220 }
221 
222 
223 } // namespace Tasks
224 } // namespace Aspose
225 
226 
Represents properties of ResourceAssignment object.
Definition: Asn.h:44
Represents a property key of a class of the specified type. An instance of this class is used when ge...
Definition: Key.h:76
K get_KeyType() const
Gets the key of the property.
Definition: Key.h:119
Represents supported properties of Project object.
Definition: Prj.h:49
Represents a built-in property.
Definition: BuiltInProjectProperty.h:37
Represents property container.
Definition: PropertyContainer.h:27
Represents supported properties of Resource object.
Definition: Rsc.h:45
Represents a task in a project.
Definition: Task.h:384
Represents properties of Task object.
Definition: Tsk.h:46
Definition: Asn.h:13