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