ComputingPowerRequestStrategy.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package RobotComponents
19  * @author Raphael Grimm ( raphael dot grimm at kit dot edu )
20  * @date 2015
21  * @copyright http://www.gnu.org/licenses/gpl.txt
22  * GNU General Public License
23  */
24 #pragma once
25 
26 #include <chrono>
27 #include <numeric>
28 
31 
32 #include <RobotComponents/interface/components/MotionPlanning/ResourceRequestStrategies/ComputingPowerRequestStrategy.h>
33 
34 namespace armarx::cprs
35 {
36  /**
37  * @brief Implementation of ComputingPowerRequestStrategyBase
38  * @see ComputingPowerRequestStrategyBase
39  */
41  virtual public ComputingPowerRequestStrategyBase
42  {
43  public:
44  /**
45  * @brief Dtor
46  */
47  ~ComputingPowerRequestStrategy() override = default;
48 
49  /**
50  * @brief Default implementation. Does nothing.
51  * @see ComputingPowerRequestStrategyBase::setCurrentStateAsInitialState
52  */
53  void setCurrentStateAsInitialState(const ::Ice::Current& = Ice::emptyCurrent) override
54  {
55  }
56 
57  /**
58  * @brief Default implementation. Does nothing.
59  * @see ComputingPowerRequestStrategyBase::updateNodeCount
60  */
61  void updateNodeCount(Ice::Long, const Ice::Current& = Ice::emptyCurrent) override
62  {
63  }
64  /**
65  * @brief Default implementation. Does nothing.
66  * @see ComputingPowerRequestStrategyBase::updateTaskStatus
67  */
68  void updateTaskStatus(armarx::TaskStatus::Status, const Ice::Current& = Ice::emptyCurrent) override
69  {
70  }
71 
72  /**
73  * @brief Default implementation. Does nothing.
74  * @see ComputingPowerRequestStrategyBase::allocatedComputingPower
75  */
76  void allocatedComputingPower(const Ice::Current& = Ice::emptyCurrent) override
77  {
78  }
79 
80  /**
81  * @brief Default implementation. Does nothing.
82  * @see ComputingPowerRequestStrategyBase::updateNodeCreations
83  */
84  void updateNodeCreations(Ice::Long, Ice::Long, const Ice::Current& = Ice::emptyCurrent) override
85  {
86  }
87 
88  /**
89  * @brief Returns whether new computing power should be allocated.
90  * Pure virtual.
91  * @see ComputingPowerRequestStrategyBase::shouldAllocateComputingPower
92  * @return Whether new computing power should be allocated.
93  */
94  bool shouldAllocateComputingPower(const ::Ice::Current& = Ice::emptyCurrent) override = 0;
95  };
97 
98  /**
99  * @brief Implementation of CompoundedRequestStrategyBase
100  * @see CompoundedRequestStrategyBase
101  */
103  virtual public CompoundedRequestStrategyBase,
104  virtual public ComputingPowerRequestStrategy
105  {
106  public:
107  /**
108  * @brief Ctor
109  * @param requestStrategies The strategies forming this compound.
110  */
111  CompoundedRequestStrategy(const ComputingPowerRequestStrategyBaseList& requestStrategies): CompoundedRequestStrategyBase(requestStrategies) {}
112 
113  /**
114  * @brief Calls this function for all compounded strategies.
115  * @see ComputingPowerRequestStrategyBase::setCurrentStateAsInitialState
116  */
117  void setCurrentStateAsInitialState(const ::Ice::Current& = Ice::emptyCurrent) override;
118  /**
119  * @brief Calls this function for all compounded strategies.
120  * @see ComputingPowerRequestStrategyBase::updateNodeCount
121  * @param count The new node count
122  */
123  void updateNodeCount(Ice::Long count, const Ice::Current& = Ice::emptyCurrent) override;
124 
125  /**
126  * @brief Calls this function for all compounded strategies.
127  * @see ComputingPowerRequestStrategyBase::updateTaskStatus
128  * @param newStatus The new status
129  */
130  void updateTaskStatus(armarx::TaskStatus::Status newStatus, const Ice::Current& = Ice::emptyCurrent) override;
131 
132  /**
133  * @brief Calls this function for all compounded strategies.
134  * @see ComputingPowerRequestStrategyBase::allocatedComputingPower
135  */
136  void allocatedComputingPower(const Ice::Current& = Ice::emptyCurrent) override;
137 
138  /**
139  * @brief Passes this call to all sub strategies.
140  * @see ComputingPowerRequestStrategyBase::updateNodeCreations
141  * @param nodesCreated Number of created nodes.
142  * @param tries Number of tries to create nodes.
143  */
144  void updateNodeCreations(Ice::Long nodesCreated, Ice::Long tries, const Ice::Current& = Ice::emptyCurrent) override;
145 
146  protected:
147  //for object factory
148  template<class Base, class Derived> friend class armarx::GenericFactory;
149  /**
150  * @brief Ctor used for object factories.
151  */
152  CompoundedRequestStrategy() = default;
153  };
154 
155  /**
156  * @brief Implementation of AndBase
157  * @see AndBase
158  */
159  class And:
160  virtual public AndBase,
161  virtual public CompoundedRequestStrategy
162  {
163  public:
164  /**
165  * @brief Ctor
166  * @param requestStrategies The strategies forming this compound.
167  */
168  And(const ComputingPowerRequestStrategyBaseList& requestStrategies):
169  AndBase(requestStrategies),
170  CompoundedRequestStrategy(requestStrategies)
171  {}
172  /**
173  * @brief Returns true if all compounded strategies return true.
174  * @return True if all compounded strategies return true.
175  */
176  bool shouldAllocateComputingPower(const ::Ice::Current& = Ice::emptyCurrent) override;
177  protected:
178  //for object factory
179  template<class Base, class Derived> friend class armarx::GenericFactory;
180  /**
181  * @brief Ctor used for object factories.
182  */
183  And() = default;
184  };
186 
187  /**
188  * @brief Implementation of OrBase
189  * @see OrBase
190  */
191  class Or:
192  virtual public OrBase,
193  virtual public CompoundedRequestStrategy
194  {
195  public:
196  /**
197  * @brief Ctor
198  * @param requestStrategies The strategies forming this compound.
199  */
200  Or(const ComputingPowerRequestStrategyBaseList& requestStrategies):
201  OrBase(requestStrategies),
202  CompoundedRequestStrategy(requestStrategies)
203  {}
204  /**
205  * @brief Returns true if any compounded strategies returns true.
206  * @return True if all compounded strategies return true.
207  */
208  bool shouldAllocateComputingPower(const ::Ice::Current& = Ice::emptyCurrent) override
209  {
210  return std::any_of(requestStrategies.begin(), requestStrategies.end(),
211  [](ComputingPowerRequestStrategyBasePtr & s)
212  {
213  return s->shouldAllocateComputingPower();
214  }
215  );
216  }
217  protected:
218  //for object factory
219  template<class Base, class Derived> friend class armarx::GenericFactory;
220  /**
221  * @brief Ctor used for object factories.
222  */
223  Or() = default;
224  };
226 
227  /**
228  * @brief Implementation of NotBase
229  * @see NotBase
230  */
231  class Not:
232  virtual public NotBase,
233  virtual public ComputingPowerRequestStrategy
234  {
235  public:
236  /**
237  * @brief Ctor
238  * @param s The negated strategy.
239  */
240  Not(const ComputingPowerRequestStrategyBasePtr& s): NotBase(s) {}
241 
242  /**
243  * @brief Passes the call to the contained strategy.
244  */
245  void setCurrentStateAsInitialState(const ::Ice::Current& = Ice::emptyCurrent) override
246  {
247  allocStrat->setCurrentStateAsInitialState();
248  }
249 
250  /**
251  * @brief Passes the call to the contained strategy.
252  * @param count The new node count.
253  */
254  void updateNodeCount(Ice::Long count, const Ice::Current& = Ice::emptyCurrent) override
255  {
256  allocStrat->updateNodeCount(count);
257  }
258 
259  /**
260  * @brief Passes the call to the contained strategy.
261  * @param newStatus The new task status.
262  */
263  void updateTaskStatus(armarx::TaskStatus::Status newStatus, const Ice::Current& = Ice::emptyCurrent) override
264  {
265  allocStrat->updateTaskStatus(newStatus);
266  }
267 
268  /**
269  * @brief Passes the call to the contained strategy.
270  */
271  void allocatedComputingPower(const Ice::Current& = Ice::emptyCurrent) override
272  {
273  allocStrat->allocatedComputingPower();
274  }
275 
276  /**
277  * @brief Returns the negatedresult of the contained strategy.
278  * @return The negatedresult of the contained strategy.
279  */
280  bool shouldAllocateComputingPower(const ::Ice::Current& = Ice::emptyCurrent) override
281  {
282  return !allocStrat->shouldAllocateComputingPower();
283  }
284 
285  /**
286  * @brief Passes this call to all sub strategies.
287  * @see ComputingPowerRequestStrategyBase::updateNodeCreations
288  * @param nodesCreated Number of created nodes.
289  * @param tries Number of tries to create nodes.
290  */
291  void updateNodeCreations(Ice::Long nodesCreated, Ice::Long tries, const Ice::Current& = Ice::emptyCurrent) override
292  {
293  allocStrat->updateNodeCreations(nodesCreated, tries);
294  }
295  protected:
296  //for object factory
297  template<class Base, class Derived> friend class armarx::GenericFactory;
298  /**
299  * @brief Ctor used for object factories.
300  */
301  Not() = default;
302  };
304 
305  /**
306  * @brief Implementation of Always
307  * @see Always
308  */
309  class Always:
310  virtual public AlwaysBase,
311  virtual public ComputingPowerRequestStrategy
312  {
313  public:
314  /**
315  * @brief Always return true.
316  * @return true
317  */
318  bool shouldAllocateComputingPower(const ::Ice::Current& = Ice::emptyCurrent) override
319  {
320  return true;
321  }
322  };
324 
325  /**
326  * @brief Implementation of NeverBase
327  * @see NeverBase
328  */
329  class Never:
330  virtual public NeverBase,
331  virtual public ComputingPowerRequestStrategy
332  {
333  public:
334  /**
335  * @brief Always return false.
336  * @return false
337  */
338  bool shouldAllocateComputingPower(const ::Ice::Current& = Ice::emptyCurrent) override
339  {
340  return false;
341  }
342  };
344 
345  /**
346  * @brief Implementation of ElapsedTimeBase
347  * @see ElapsedTimeBase
348  */
349  class ElapsedTime:
350  virtual public ElapsedTimeBase,
351  virtual public ComputingPowerRequestStrategy
352  {
353  public:
354  /**
355  * @brief The used clock type.
356  */
357  using Clock = std::chrono::system_clock;
358  /**
359  * @brief The type of the used time point.
360  */
361  using TimePoint = Clock::time_point;
362 
363  /**
364  * @brief Ctor
365  * @param timeDeltaInSeconds The delta to use.(in seconds)
366  * @param skipping Whether skipping is activated.
367  */
368  ElapsedTime(Ice::Long timeDeltaInSeconds, bool skipping):
369  ElapsedTimeBase(timeDeltaInSeconds, skipping),
371  {
372  }
373 
374  /**
375  * @brief Sets the next time to allocate delta seconds from now.
376  */
377  void setCurrentStateAsInitialState(const ::Ice::Current& = Ice::emptyCurrent) override
378  {
380  }
381 
382  /**
383  * @brief Sets the next time to allocate depending on the flag skipping.
384  * skipping == true: now + delta seconds.
385  * skipping == false: the current next time point + delta seconds. (may already passed)
386  */
387  void allocatedComputingPower(const Ice::Current& = Ice::emptyCurrent) override;
388 
389  /**
390  * @brief Returns true if the last creation timepoint is more than delta seconds away.
391  * @return Whether more computing power should be allocated.
392  */
393  bool shouldAllocateComputingPower(const ::Ice::Current& = Ice::emptyCurrent) override
394  {
395  return Clock::now() >= allocatedLastTime + std::chrono::seconds {timeDeltaInSeconds};
396  }
397  protected:
398  /**
399  * @brief The time point when more power should be allocated again.
400  */
402 
403  //for object factory
404  template<class Base, class Derived> friend class armarx::GenericFactory;
405  /**
406  * @brief Ctor used for object factories.
407  */
408  ElapsedTime() = default;
409  };
411 
412 
413  /**
414  * @brief Implementation of NoNodeCreatedBase
415  * @see NoNodeCreatedBase
416  */
418  virtual public NoNodeCreatedBase,
419  virtual public ElapsedTime
420  {
421  public:
422  /**
423  * @brief ctor
424  * @param timeDeltaInSeconds The delta to use.(in seconds)
425  * @param skipping Whether skipping is activated.
426  * @param sig The parameter sigma.
427  * @param backlogSz The backlog's size.
428  */
429  NoNodeCreated(Ice::Long timeDeltaInSec, bool skip, float sig, Ice::Long backlogSz):
430  NoNodeCreatedBase(timeDeltaInSec, skip, sig, backlogSz),
431  ElapsedTime(timeDeltaInSec, skip),
432  backlog(backlogSz, 0),
434  {
435  timeDeltaInSeconds = timeDeltaInSec; //somehow does not get set by ctor call
436  ARMARX_CHECK_EXPRESSION(timeDeltaInSeconds >= 0);
437  ARMARX_CHECK_EXPRESSION(backlogSize >= 0);
438  }
439 
440  /**
441  * @brief Updates the number of failed node creations.
442  * @param nodesCreated Number of created nodes.
443  * @param tries Number of tries to create nodes.
444  */
445  void updateNodeCreations(Ice::Long nodesCreated, Ice::Long tries, const Ice::Current& = Ice::emptyCurrent) override;
446 
447  void allocatedComputingPower(const Ice::Current& = Ice::emptyCurrent) override;
448 
449  /**
450  * @brief shouldAllocateComputingPower
451  * @return Whrether
452  */
453  bool shouldAllocateComputingPower(const ::Ice::Current& = Ice::emptyCurrent) override
454  {
455  const auto perc = std::accumulate(backlog.begin(), backlog.end(), 1.f) / backlog.size();
456  const auto usedTimeDelta = timeDeltaInSeconds / (1.f + sigma * perc);
457  ARMARX_CHECK_EXPRESSION(usedTimeDelta >= 0);
458  return Clock::now() >= allocatedLastTime + std::chrono::seconds {static_cast<std::size_t>(usedTimeDelta)};
459  }
460 
461  /**
462  * @brief Nulls the backlog after the object was transmitted through ice.
463  */
464  void ice_postUnmarshal() override
465  {
466  backlog.assign(backlogSize, 0);
467  }
468 
469  protected:
470  /**
471  * @brief The backlog. chars are used instead of bools since vector<bool> is specialized.
472  * contains a 1 if a node creation failed and 0 if it was successfull;
473  */
474  std::vector<char> backlog;
475  /**
476  * @brief The current index in the backlog. (used to determine which variables will be overwritten)
477  */
478  std::size_t currentBacklogIndex;
479 
480  //for object factory
481  template<class Base, class Derived> friend class armarx::GenericFactory;
482  /**
483  * @brief Ctor used for object factories.
484  */
485  NoNodeCreated() = default;
486  };
488 
489  /**
490  * @brief Implementation of TotalNodeCountBase
491  * @see TotalNodeCountBase
492  */
494  virtual public TotalNodeCountBase,
495  virtual public ComputingPowerRequestStrategy
496  {
497  public:
498  /**
499  * @brief Ctor
500  * @param nodeCountDelta The delta to use.
501  * @param skipping Whether skipping is activated.
502  */
503  TotalNodeCount(Ice::Long nodeCountDelta, bool skipping):
504  TotalNodeCountBase(nodeCountDelta, skipping),
505  allocateNextTime {0},
506  nodeCount {0}
507  {
508  }
509 
510  /**
511  * @brief Updates the internal node count.
512  * @param newCount The new node count.
513  */
514  void updateNodeCount(Ice::Long newCount, const Ice::Current& = Ice::emptyCurrent) override
515  {
516  nodeCount = newCount;
517  }
518 
519  /**
520  * @brief Sets the next creation count to allocate depending on the flag skipping.
521  * skipping == true: current count + delta.
522  * skipping == false: the current next creation count + delta. (may be smaller than the current count)
523  */
524  void allocatedComputingPower(const Ice::Current& = Ice::emptyCurrent) override;
525 
526  /**
527  * @brief Returns true if the the current count is >= the next creation count.
528  * @return Whether more computing power should be allocated.
529  */
530  bool shouldAllocateComputingPower(const ::Ice::Current& = Ice::emptyCurrent) override
531  {
532  return nodeCount >= allocateNextTime;
533  }
534 
535  protected:
536  /**
537  * @brief The count when to allocate more power.
538  */
540  /**
541  * @brief The current node count.
542  */
544 
545  //for object factory
546  template<class Base, class Derived> friend class armarx::GenericFactory;
547  /**
548  * @brief Ctor used for object factories.
549  */
551  };
553 
554  /**
555  * @brief Implementation of TaskStatusBase
556  * @see TaskStatusBase
557  */
558  class TaskStatus:
559  virtual public TaskStatusBase,
560  virtual public ComputingPowerRequestStrategy
561  {
562  public:
563  /**
564  * @brief Ctor
565  * @param strategyPerTaskStatus Task status to sub strategy map.
566  */
567  TaskStatus(TaskStatusMap strategyPerTaskStatus):
568  TaskStatusBase(strategyPerTaskStatus),
569  current {nullptr}
570  {
571  }
572 
573  /**
574  * @brief Passes this call to all sub strategies.
575  * @param count The new count
576  */
577  void updateNodeCount(Ice::Long count, const Ice::Current& = Ice::emptyCurrent) override;
578 
579  /**
580  * @brief Switches the current strategy and passes this call to all sub strategies.
581  * @param newStatus
582  */
583  void updateTaskStatus(armarx::TaskStatus::Status newStatus, const Ice::Current& = Ice::emptyCurrent) override;
584 
585  /**
586  * @brief Passes this call to all sub strategies.
587  */
588  void allocatedComputingPower(const Ice::Current& = Ice::emptyCurrent) override;
589 
590  /**
591  * @brief Passes this call to all sub strategies.
592  * @see ComputingPowerRequestStrategyBase::updateNodeCreations
593  * @param nodesCreated Number of created nodes.
594  * @param tries Number of tries to create nodes.
595  */
596  void updateNodeCreations(Ice::Long nodesCreated, Ice::Long tries, const Ice::Current& = Ice::emptyCurrent) override;
597 
598  /**
599  * @brief Returns the result of the current selected strategy.
600  * @return The result of the current selected strategy.
601  */
602  bool shouldAllocateComputingPower(const ::Ice::Current& = Ice::emptyCurrent) override
603  {
605  return current->shouldAllocateComputingPower();
606  }
607  protected:
608  /**
609  * @brief The current strategy in use.
610  */
611  ComputingPowerRequestStrategyBase* current;
612 
613  //for object factory
614  template<class Base, class Derived> friend class armarx::GenericFactory;
615  /**
616  * @brief Ctor used for object factories.
617  */
618  TaskStatus(): current {nullptr} {}
619  };
621 }
622 
armarx::cprs::NoNodeCreated::NoNodeCreated
NoNodeCreated(Ice::Long timeDeltaInSec, bool skip, float sig, Ice::Long backlogSz)
ctor
Definition: ComputingPowerRequestStrategy.h:429
armarx::cprs::Always::shouldAllocateComputingPower
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Always return true.
Definition: ComputingPowerRequestStrategy.h:318
armarx::cprs::ElapsedTime::ElapsedTime
ElapsedTime()=default
Ctor used for object factories.
armarx::cprs::ElapsedTime::shouldAllocateComputingPower
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns true if the last creation timepoint is more than delta seconds away.
Definition: ComputingPowerRequestStrategy.h:393
armarx::cprs::Not::shouldAllocateComputingPower
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns the negatedresult of the contained strategy.
Definition: ComputingPowerRequestStrategy.h:280
armarx::cprs::ComputingPowerRequestStrategy::updateNodeCreations
void updateNodeCreations(Ice::Long, Ice::Long, const Ice::Current &=Ice::emptyCurrent) override
Default implementation.
Definition: ComputingPowerRequestStrategy.h:84
armarx::cprs::Never
Implementation of NeverBase.
Definition: ComputingPowerRequestStrategy.h:329
armarx::cprs::ComputingPowerRequestStrategy::allocatedComputingPower
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Default implementation.
Definition: ComputingPowerRequestStrategy.h:76
armarx::cprs::TotalNodeCount::shouldAllocateComputingPower
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns true if the the current count is >= the next creation count.
Definition: ComputingPowerRequestStrategy.h:530
armarx::cprs::CompoundedRequestStrategy::CompoundedRequestStrategy
CompoundedRequestStrategy(const ComputingPowerRequestStrategyBaseList &requestStrategies)
Ctor.
Definition: ComputingPowerRequestStrategy.h:111
armarx::cprs::CompoundedRequestStrategy::updateTaskStatus
void updateTaskStatus(armarx::TaskStatus::Status newStatus, const Ice::Current &=Ice::emptyCurrent) override
Calls this function for all compounded strategies.
Definition: ComputingPowerRequestStrategy.cpp:140
armarx::cprs::TotalNodeCount::updateNodeCount
void updateNodeCount(Ice::Long newCount, const Ice::Current &=Ice::emptyCurrent) override
Updates the internal node count.
Definition: ComputingPowerRequestStrategy.h:514
armarx::cprs::TotalNodeCount::allocateNextTime
Ice::Long allocateNextTime
The count when to allocate more power.
Definition: ComputingPowerRequestStrategy.h:539
armarx::cprs::And::shouldAllocateComputingPower
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns true if all compounded strategies return true.
Definition: ComputingPowerRequestStrategy.cpp:29
armarx::cprs::NoNodeCreated::shouldAllocateComputingPower
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
shouldAllocateComputingPower
Definition: ComputingPowerRequestStrategy.h:453
FactoryCollectionBase.h
armarx::cprs::NoNodeCreated::NoNodeCreated
NoNodeCreated()=default
Ctor used for object factories.
armarx::cprs::ComputingPowerRequestStrategy::updateNodeCount
void updateNodeCount(Ice::Long, const Ice::Current &=Ice::emptyCurrent) override
Default implementation.
Definition: ComputingPowerRequestStrategy.h:61
armarx::cprs::NoNodeCreated::currentBacklogIndex
std::size_t currentBacklogIndex
The current index in the backlog.
Definition: ComputingPowerRequestStrategy.h:478
armarx::cprs::Not::allocatedComputingPower
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Passes the call to the contained strategy.
Definition: ComputingPowerRequestStrategy.h:271
armarx::cprs::TotalNodeCount
Implementation of TotalNodeCountBase.
Definition: ComputingPowerRequestStrategy.h:493
armarx::cprs::ComputingPowerRequestStrategy::setCurrentStateAsInitialState
void setCurrentStateAsInitialState(const ::Ice::Current &=Ice::emptyCurrent) override
Default implementation.
Definition: ComputingPowerRequestStrategy.h:53
armarx::cprs::NoNodeCreated
Implementation of NoNodeCreatedBase.
Definition: ComputingPowerRequestStrategy.h:417
armarx::cprs::Not::setCurrentStateAsInitialState
void setCurrentStateAsInitialState(const ::Ice::Current &=Ice::emptyCurrent) override
Passes the call to the contained strategy.
Definition: ComputingPowerRequestStrategy.h:245
armarx::cprs
Definition: ComputingPowerRequestStrategy.h:34
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::cprs::TaskStatus::updateNodeCount
void updateNodeCount(Ice::Long count, const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
Definition: ComputingPowerRequestStrategy.cpp:63
armarx::cprs::ComputingPowerRequestStrategy::shouldAllocateComputingPower
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override=0
Returns whether new computing power should be allocated.
armarx::cprs::TaskStatus::updateNodeCreations
void updateNodeCreations(Ice::Long nodesCreated, Ice::Long tries, const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
Definition: ComputingPowerRequestStrategy.cpp:90
armarx::cprs::CompoundedRequestStrategy::updateNodeCount
void updateNodeCount(Ice::Long count, const Ice::Current &=Ice::emptyCurrent) override
Calls this function for all compounded strategies.
Definition: ComputingPowerRequestStrategy.cpp:132
armarx::cprs::NoNodeCreated::backlog
std::vector< char > backlog
The backlog.
Definition: ComputingPowerRequestStrategy.h:474
armarx::cprs::And::And
And()=default
Ctor used for object factories.
armarx::cprs::TotalNodeCount::nodeCount
Ice::Long nodeCount
The current node count.
Definition: ComputingPowerRequestStrategy.h:543
armarx::VariantType::Long
const VariantTypeId Long
Definition: Variant.h:917
armarx::cprs::CompoundedRequestStrategy::setCurrentStateAsInitialState
void setCurrentStateAsInitialState(const ::Ice::Current &=Ice::emptyCurrent) override
Calls this function for all compounded strategies.
Definition: ComputingPowerRequestStrategy.cpp:124
armarx::cprs::TaskStatus::TaskStatus
TaskStatus()
Ctor used for object factories.
Definition: ComputingPowerRequestStrategy.h:618
armarx::cprs::Or::Or
Or(const ComputingPowerRequestStrategyBaseList &requestStrategies)
Ctor.
Definition: ComputingPowerRequestStrategy.h:200
armarx::cprs::TaskStatus::current
ComputingPowerRequestStrategyBase * current
The current strategy in use.
Definition: ComputingPowerRequestStrategy.h:611
armarx::cprs::ElapsedTime::TimePoint
Clock::time_point TimePoint
The type of the used time point.
Definition: ComputingPowerRequestStrategy.h:361
armarx::cprs::NoNodeCreated::allocatedComputingPower
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Definition: ComputingPowerRequestStrategy.cpp:108
ExpressionException.h
armarx::cprs::Not
Implementation of NotBase.
Definition: ComputingPowerRequestStrategy.h:231
ARMARX_CHECK_EXPRESSION
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
Definition: ExpressionException.h:73
armarx::cprs::Not::updateNodeCount
void updateNodeCount(Ice::Long count, const Ice::Current &=Ice::emptyCurrent) override
Passes the call to the contained strategy.
Definition: ComputingPowerRequestStrategy.h:254
armarx::cprs::Or
Implementation of OrBase.
Definition: ComputingPowerRequestStrategy.h:191
armarx::cprs::ElapsedTime::allocatedLastTime
TimePoint allocatedLastTime
The time point when more power should be allocated again.
Definition: ComputingPowerRequestStrategy.h:401
armarx::cprs::NoNodeCreated::ice_postUnmarshal
void ice_postUnmarshal() override
Nulls the backlog after the object was transmitted through ice.
Definition: ComputingPowerRequestStrategy.h:464
armarx::cprs::ElapsedTime
Implementation of ElapsedTimeBase.
Definition: ComputingPowerRequestStrategy.h:349
armarx::cprs::TaskStatus::allocatedComputingPower
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
Definition: ComputingPowerRequestStrategy.cpp:82
armarx::cprs::ElapsedTime::allocatedComputingPower
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Sets the next time to allocate depending on the flag skipping.
Definition: ComputingPowerRequestStrategy.cpp:39
armarx::cprs::TotalNodeCount::TotalNodeCount
TotalNodeCount(Ice::Long nodeCountDelta, bool skipping)
Ctor.
Definition: ComputingPowerRequestStrategy.h:503
armarx::cprs::TotalNodeCount::TotalNodeCount
TotalNodeCount()
Ctor used for object factories.
Definition: ComputingPowerRequestStrategy.h:550
armarx::cprs::TaskStatus
Implementation of TaskStatusBase.
Definition: ComputingPowerRequestStrategy.h:558
armarx::cprs::Not::Not
Not(const ComputingPowerRequestStrategyBasePtr &s)
Ctor.
Definition: ComputingPowerRequestStrategy.h:240
armarx::cprs::Always
Implementation of Always.
Definition: ComputingPowerRequestStrategy.h:309
armarx::cprs::Not::updateTaskStatus
void updateTaskStatus(armarx::TaskStatus::Status newStatus, const Ice::Current &=Ice::emptyCurrent) override
Passes the call to the contained strategy.
Definition: ComputingPowerRequestStrategy.h:263
armarx::cprs::ComputingPowerRequestStrategy::~ComputingPowerRequestStrategy
~ComputingPowerRequestStrategy() override=default
Dtor.
armarx::GenericFactory
Definition: FactoryCollectionBase.h:51
armarx::cprs::TaskStatus::shouldAllocateComputingPower
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns the result of the current selected strategy.
Definition: ComputingPowerRequestStrategy.h:602
armarx::cprs::TaskStatus::TaskStatus
TaskStatus(TaskStatusMap strategyPerTaskStatus)
Ctor.
Definition: ComputingPowerRequestStrategy.h:567
armarx::cprs::ComputingPowerRequestStrategy::updateTaskStatus
void updateTaskStatus(armarx::TaskStatus::Status, const Ice::Current &=Ice::emptyCurrent) override
Default implementation.
Definition: ComputingPowerRequestStrategy.h:68
armarx::cprs::And::And
And(const ComputingPowerRequestStrategyBaseList &requestStrategies)
Ctor.
Definition: ComputingPowerRequestStrategy.h:168
armarx::cprs::And
Implementation of AndBase.
Definition: ComputingPowerRequestStrategy.h:159
armarx::cprs::CompoundedRequestStrategy::updateNodeCreations
void updateNodeCreations(Ice::Long nodesCreated, Ice::Long tries, const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
Definition: ComputingPowerRequestStrategy.cpp:156
armarx::cprs::Or::Or
Or()=default
Ctor used for object factories.
armarx::cprs::ComputingPowerRequestStrategy
Implementation of ComputingPowerRequestStrategyBase.
Definition: ComputingPowerRequestStrategy.h:40
armarx::cprs::TaskStatus::updateTaskStatus
void updateTaskStatus(armarx::TaskStatus::Status newStatus, const Ice::Current &=Ice::emptyCurrent) override
Switches the current strategy and passes this call to all sub strategies.
Definition: ComputingPowerRequestStrategy.cpp:71
armarx::cprs::Or::shouldAllocateComputingPower
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns true if any compounded strategies returns true.
Definition: ComputingPowerRequestStrategy.h:208
armarx::cprs::CompoundedRequestStrategy::allocatedComputingPower
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Calls this function for all compounded strategies.
Definition: ComputingPowerRequestStrategy.cpp:148
armarx::cprs::ElapsedTime::setCurrentStateAsInitialState
void setCurrentStateAsInitialState(const ::Ice::Current &=Ice::emptyCurrent) override
Sets the next time to allocate delta seconds from now.
Definition: ComputingPowerRequestStrategy.h:377
armarx::cprs::Never::shouldAllocateComputingPower
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Always return false.
Definition: ComputingPowerRequestStrategy.h:338
armarx::cprs::Not::updateNodeCreations
void updateNodeCreations(Ice::Long nodesCreated, Ice::Long tries, const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
Definition: ComputingPowerRequestStrategy.h:291
armarx::cprs::ElapsedTime::ElapsedTime
ElapsedTime(Ice::Long timeDeltaInSeconds, bool skipping)
Ctor.
Definition: ComputingPowerRequestStrategy.h:368
armarx::cprs::TotalNodeCount::allocatedComputingPower
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Sets the next creation count to allocate depending on the flag skipping.
Definition: ComputingPowerRequestStrategy.cpp:51
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
armarx::cprs::ElapsedTime::Clock
std::chrono::system_clock Clock
The used clock type.
Definition: ComputingPowerRequestStrategy.h:357
armarx::cprs::CompoundedRequestStrategy::CompoundedRequestStrategy
CompoundedRequestStrategy()=default
Ctor used for object factories.
armarx::cprs::Not::Not
Not()=default
Ctor used for object factories.
armarx::cprs::NoNodeCreated::updateNodeCreations
void updateNodeCreations(Ice::Long nodesCreated, Ice::Long tries, const Ice::Current &=Ice::emptyCurrent) override
Updates the number of failed node creations.
Definition: ComputingPowerRequestStrategy.cpp:98
armarx::core::time::Clock::now
DateTime now() const
Current date/time of the clock.
Definition: Clock.cpp:23
armarx::cprs::CompoundedRequestStrategy
Implementation of CompoundedRequestStrategyBase.
Definition: ComputingPowerRequestStrategy.h:102