Aspose.Tasks for C++
RateCollection.h
1 #pragma once
2 //-----------------------------------------------------------------------
3 // <copyright file="RateCollection.cs" company="Aspose Pty Ltd">
4 // Copyright (c) 2002-2024 Aspose Pty Ltd. All Rights Reserved.
5 // </copyright>
6 //-----------------------------------------------------------------------
7 
8 #include <system/collections/idictionary.h>
9 #include <system/array.h>
10 #include <cstdint>
11 
12 #include "aspose.tasks.cpp/Enums/RateType.h"
13 #include "aspose.tasks.cpp/aspose_tasks_api_defs.h"
14 
15 namespace Aspose
16 {
17 namespace Tasks
18 {
19 class AutoRecalculationState;
20 namespace Calculations
21 {
22 class RateByDateEnumeratorBase;
23 } // namespace Calculations
24 namespace Connectivity
25 {
26 class MpdReader;
27 class MpdResourceRateMapper;
28 class PmResourceRateMapper;
29 } // namespace Connectivity
30 namespace IO
31 {
32 namespace MSProject
33 {
34 class MPPResourceReader;
35 } // namespace MSProject
36 namespace PrimaveraXml
37 {
38 class PrimaveraResourceRateNodeReader;
39 } // namespace PrimaveraXml
40 namespace Xer
41 {
42 class XerResourceRateReader;
43 class XerUtils;
44 } // namespace Xer
45 namespace Xml
46 {
47 class RateNodeReader;
48 class ResourceNodeReader;
49 } // namespace Xml
50 } // namespace IO
51 class Rate;
52 class RateByDateCollection;
53 class Resource;
54 class ResourceAssignment;
55 } // namespace Tasks
56 } // namespace Aspose
57 namespace System
58 {
59 namespace Collections
60 {
61 namespace Generic
62 {
63 template <typename> class ICollection;
64 template <typename> class IEnumerable;
65 template <typename> class IEnumerator;
66 template <typename, typename> class KeyValuePair;
67 template <typename> class List;
68 } // namespace Generic
69 } // namespace Collections
70 class DateTime;
71 } // namespace System
72 
73 namespace Aspose {
74 
75 namespace Tasks {
76 
77 /// <summary>
78 /// Represents a collection which contains <see cref="Rate"></see> objects.
79 /// </summary>
80 class ASPOSE_TASKS_SHARED_CLASS RateCollection : public System::Collections::Generic::IDictionary<Aspose::Tasks::RateType, System::SharedPtr<Aspose::Tasks::RateByDateCollection>>
81 {
82  typedef RateCollection ThisType;
83  typedef System::Collections::Generic::IDictionary<Aspose::Tasks::RateType, System::SharedPtr<Aspose::Tasks::RateByDateCollection>> BaseType;
84 
85  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
86  ASPOSE_TASKS_SHARED_RTTI_INFO_DECL();
87 
88  friend class Aspose::Tasks::Calculations::RateByDateEnumeratorBase;
89  friend class Aspose::Tasks::IO::PrimaveraXml::PrimaveraResourceRateNodeReader;
90  friend class Aspose::Tasks::Resource;
92  friend class Aspose::Tasks::Connectivity::MpdReader;
93  friend class Aspose::Tasks::Connectivity::MpdResourceRateMapper;
94  friend class Aspose::Tasks::Connectivity::PmResourceRateMapper;
95  friend class Aspose::Tasks::IO::MSProject::MPPResourceReader;
96  friend class Aspose::Tasks::IO::Xer::XerResourceRateReader;
97  friend class Aspose::Tasks::IO::Xer::XerUtils;
98  friend class Aspose::Tasks::IO::Xml::RateNodeReader;
99  friend class Aspose::Tasks::IO::Xml::ResourceNodeReader;
100  friend class Aspose::Tasks::AutoRecalculationState;
101 
102 public:
103 
104  /// <summary>
105  /// Gets the number of elements contained in the RateCollection.
106  /// </summary>
107  ASPOSE_TASKS_SHARED_API int32_t get_Count() const override;
108  /// <summary>
109  /// Gets a value indicating whether this collection is read only.
110  /// </summary>
111  ASPOSE_TASKS_SHARED_API bool get_IsReadOnly() const override;
112  /// <summary>
113  /// Gets the parent <see cref="Resource"></see> object for this collection.
114  /// </summary>
115  ASPOSE_TASKS_SHARED_API System::SharedPtr<Resource> get_ParentResource() const;
116 
117  /// <summary>
118  /// Returns the element at the specified index.
119  /// </summary>
120  /// <param name="key">The zero-based index of the element to get or set.</param>
121  /// <returns>the element at the specified index.</returns>
122  ASPOSE_TASKS_SHARED_API System::SharedPtr<RateByDateCollection> idx_get(const RateType& key) const override;
123  /// <summary>
124  /// Sets the element at the specified index.
125  /// </summary>
126  /// <param name="key">The zero-based index of the element to get or set.</param>
127  /// <param name="value">the element at the specified index.</param>
128  ASPOSE_TASKS_SHARED_API void idx_set(const RateType& key, System::SharedPtr<RateByDateCollection> value) override;
129 
130  /// <summary>
131  /// Adds a new <see cref="Rate"></see> instance to this collection.
132  /// </summary>
133  /// <param name="ratesFrom">The date the new rate comes into effect.</param>
134  /// <returns>Added <see cref="Rate"></see> instance.</returns>
135  ASPOSE_TASKS_SHARED_API System::SharedPtr<Rate> Add(System::DateTime ratesFrom);
136  /// <summary>
137  /// Adds a new <see cref="Rate"></see> instance to this collection.
138  /// </summary>
139  /// <param name="ratesFrom">The date the new rate comes into effect.</param>
140  /// <param name="type">The rate table to add into.</param>
141  /// <returns>Added <see cref="Rate"></see> instance.</returns>
142  ASPOSE_TASKS_SHARED_API System::SharedPtr<Rate> Add(System::DateTime ratesFrom, RateType type);
143  /// <summary>
144  /// Removes Rate instance from this collection.
145  /// </summary>
146  /// <param name="item">The item to remove.</param>
147  /// <returns>true if the specified Rate was removed successfully; otherwise, false.</returns>
148  ASPOSE_TASKS_SHARED_API bool Remove(const System::SharedPtr<Rate>& item);
149  /// <summary>
150  /// Converts the <see cref="RateCollection"></see> object to a list of <see cref="Rate"></see> objects.
151  /// </summary>
152  /// <returns>List of <see cref="Rate"></see> objects.</returns>
153  ASPOSE_TASKS_SHARED_API System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<Rate>>> ToList() const;
154  /// <summary>
155  /// Converts the <see cref="RateCollection"></see> object to a list of <see cref="Rate"></see> objects filtered by specified <see cref="RateType"></see> type.
156  /// </summary>
157  /// <param name="type">The type to filter on.</param>
158  /// <returns>a list of <see cref="Rate"></see> objects.</returns>
159  ASPOSE_TASKS_SHARED_API System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<Rate>>> ToList(RateType type) const;
160 
161 protected:
162 
163  ASPOSE_TASKS_SHARED_API RateCollection(const System::SharedPtr<Resource>& rsc);
164 
165  ASPOSE_TASKS_SHARED_API MEMBER_FUNCTION_MAKE_OBJECT_DECLARATION(RateCollection, CODEPORTING_ARGS(const System::SharedPtr<Resource>& rsc));
166 
167  ASPOSE_TASKS_SHARED_API RateCollection(const System::SharedPtr<Resource>& rsc, const System::SharedPtr<System::Collections::Generic::ICollection<System::SharedPtr<Rate>>>& rates);
168 
169  ASPOSE_TASKS_SHARED_API MEMBER_FUNCTION_MAKE_OBJECT_DECLARATION(RateCollection, CODEPORTING_ARGS(const System::SharedPtr<Resource>& rsc, const System::SharedPtr<System::Collections::Generic::ICollection<System::SharedPtr<Rate>>>& rates));
170  ASPOSE_TASKS_SHARED_API void AddRange(const System::SharedPtr<System::Collections::Generic::IEnumerable<System::SharedPtr<Rate>>>& rateCollection);
171  ASPOSE_TASKS_SHARED_API System::SharedPtr<Rate> Add(const System::SharedPtr<Rate>& rate);
172  ASPOSE_TASKS_SHARED_API System::SharedPtr<Rate> CreateRate();
173  ASPOSE_TASKS_SHARED_API void SetAsMaterial();
174  ASPOSE_TASKS_SHARED_API System::SharedPtr<Rate> GetFirstOrDefault(RateType rateType);
175  /// <summary>
176  /// Converts the <see cref="RateCollection"></see> object to a list of <see cref="Rate"></see> objects filtered by specified <see cref="RateType"></see> type.
177  /// </summary>
178  /// <param name="type">The type to filter on.</param>
179  /// <returns>a list of <see cref="Rate"></see> objects.</returns>
180  ASPOSE_TASKS_SHARED_API System::SharedPtr<RateByDateCollection> GetByType(RateType type);
181 
182  virtual ASPOSE_TASKS_SHARED_API ~RateCollection();
183 
184  #ifdef ASPOSE_GET_SHARED_MEMBERS
185  ASPOSE_TASKS_SHARED_API void GetSharedMembers(System::Object::shared_members_type& result) const override;
186  #endif
187 
188 
189 private:
190 
191  static System::DateTime& RatesFromMin();
192 
193  System::SharedPtr<System::Collections::Generic::IDictionary<RateType, System::SharedPtr<RateByDateCollection>>> rates;
194  System::WeakPtr<Resource> parentResource;
195 
196  /// <inheritdoc/>
197  System::SharedPtr<System::Collections::Generic::ICollection<RateType>> get_Keys() const override;
198  /// <inheritdoc/>
199  System::SharedPtr<System::Collections::Generic::ICollection<System::SharedPtr<RateByDateCollection>>> get_Values() const override;
200 
201  /// <summary>
202  /// Returns an enumerator for this collection.
203  /// </summary>
204  /// <returns>an enumerator for this collection.</returns>
205  System::SharedPtr<System::Collections::Generic::IEnumerator<System::Collections::Generic::KeyValuePair<RateType, System::SharedPtr<RateByDateCollection>>>> GetEnumerator() override;
206  /// <inheritdoc/>
207  void Add(const System::Collections::Generic::KeyValuePair<RateType, System::SharedPtr<RateByDateCollection>>& item) override;
208  /// <inheritdoc/>
209  void Clear() override;
210  /// <inheritdoc/>
211  bool Contains(const System::Collections::Generic::KeyValuePair<RateType, System::SharedPtr<RateByDateCollection>>& item) const override;
212  /// <inheritdoc/>
213  void CopyTo(System::ArrayPtr<System::Collections::Generic::KeyValuePair<RateType, System::SharedPtr<RateByDateCollection>>> array, int32_t arrayIndex) override;
214  /// <inheritdoc/>
215  bool Remove(const System::Collections::Generic::KeyValuePair<RateType, System::SharedPtr<RateByDateCollection>>& item) override;
216  /// <inheritdoc/>
217  bool ContainsKey(const RateType& key) const override;
218  /// <inheritdoc/>
219  void Add(const RateType& key, const System::SharedPtr<RateByDateCollection>& value) override;
220  /// <inheritdoc/>
221  bool Remove(const RateType& key) override;
222  /// <inheritdoc/>
223  bool TryGetValue(const RateType& key, System::SharedPtr<RateByDateCollection>& value) const override;
224  System::SharedPtr<Rate> GetLast(RateType type);
225 
226 };
227 
228 } // namespace Tasks
229 } // namespace Aspose
230 
231 
Represents a collection which contains Rate objects.
Definition: RateCollection.h:80
Represents a resource assignment in a project.
Definition: ResourceAssignment.h:221
Represents a resource in a project.
Definition: Resource.h:206