Aspose.Tasks for C++
TaskUtils.h
1 #pragma once
2 //-----------------------------------------------------------------------
3 // <copyright file="TaskUtils.cs" company="Aspose Pty Ltd">
4 // Copyright (c) 2002-2024 Aspose Pty Ltd. All Rights Reserved.
5 // </copyright>
6 //-----------------------------------------------------------------------
7 
8 #include <cstdint>
9 
10 #include "aspose.tasks.cpp/aspose_tasks_api_defs.h"
11 
12 namespace Aspose
13 {
14 namespace Tasks
15 {
16 class Task;
17 namespace Util
18 {
19 template <typename> class ICondition;
20 template <typename> class ITreeAlgorithm;
21 } // namespace Util
22 } // namespace Tasks
23 } // namespace Aspose
24 namespace System
25 {
26 template <typename> class SmartPtr;
27 template <typename T0> using SharedPtr = System::SmartPtr<T0>;
28 } // namespace System
29 
30 namespace Aspose {
31 
32 namespace Tasks {
33 
34 namespace Util {
35 
36 /// <summary>
37 /// Helper class which provides useful operations with tasks.
38 /// </summary>
39 class ASPOSE_TASKS_SHARED_CLASS TaskUtils
40 {
41  typedef TaskUtils ThisType;
42 
43 public:
44 
45  /// <summary>
46  /// Applies specified algorithm to each task of a tree.
47  /// </summary>
48  /// <param name="root">Root of the tree</param>
49  /// <param name="alg">Applied algorithm.</param>
50  /// <param name="level">Level of the root task.</param>
51  static ASPOSE_TASKS_SHARED_API void Apply(const System::SharedPtr<Task>& root, const System::SharedPtr<ITreeAlgorithm<System::SharedPtr<Task>>>& alg, int32_t level);
52  /// <summary>
53  /// Builds new tree of tasks which satisfy the condition.
54  /// </summary>
55  /// <param name="root">Root of the tree.</param>
56  /// <param name="cond">Applied condition.</param>
57  /// <returns>Root of a new tree.</returns>
58  static ASPOSE_TASKS_SHARED_API System::SharedPtr<Task> Filter(const System::SharedPtr<Task>& root, const System::SharedPtr<ICondition<System::SharedPtr<Task>>>& cond);
59  /// <summary>
60  /// Finds a task which satisfy the condition in a tree of tasks.
61  /// </summary>
62  /// <param name="root">Root of the tree.</param>
63  /// <param name="cond">Applied condition.</param>
64  /// <returns>Task if task was found, otherwise null.</returns>
65  static ASPOSE_TASKS_SHARED_API System::SharedPtr<Task> Find(const System::SharedPtr<Task>& root, const System::SharedPtr<ICondition<System::SharedPtr<Task>>>& cond);
66  /// <summary>
67  /// Recursively calculates a number of task's children tasks through all levels.
68  /// </summary>
69  /// <param name="task">The task which children calculate.</param>
70  /// <returns>The number of children.</returns>
71  static ASPOSE_TASKS_SHARED_API int32_t TaskChildrenCount(const System::SharedPtr<Task>& task);
72 
73 public:
74  TaskUtils() = delete;
75 };
76 
77 } // namespace Util
78 } // namespace Tasks
79 } // namespace Aspose
80 
81 
Represents a condition which can be used by filters or search methods.
Definition: ICondition.h:22
Represents an algorithm that can be applied to a tree of objects T .
Definition: ITreeAlgorithm.h:23
Helper class which provides useful operations with tasks.
Definition: TaskUtils.h:40
static System::SharedPtr< Task > Find(const System::SharedPtr< Task > &root, const System::SharedPtr< ICondition< System::SharedPtr< Task >>> &cond)
Finds a task which satisfy the condition in a tree of tasks.
static System::SharedPtr< Task > Filter(const System::SharedPtr< Task > &root, const System::SharedPtr< ICondition< System::SharedPtr< Task >>> &cond)
Builds new tree of tasks which satisfy the condition.
static int32_t TaskChildrenCount(const System::SharedPtr< Task > &task)
Recursively calculates a number of task's children tasks through all levels.
static void Apply(const System::SharedPtr< Task > &root, const System::SharedPtr< ITreeAlgorithm< System::SharedPtr< Task >>> &alg, int32_t level)
Applies specified algorithm to each task of a tree.
Definition: Asn.h:13