Atoms Crowd  7.0.0
DynamicLayoutGenerator.h
1 #pragma once
2 // ===========================================================================
3 // Copyright (c) 2015 Toolchefs Ltd. All rights reserved.
4 //
5 // Use of this software is subject to the terms of the Toolchefs license
6 // agreement provided at the time of installation or download, or which
7 // otherwise accompanies this software in either electronic or hard copy form.
8 // ===========================================================================
9 
10 #include <Atoms/LayoutGenerators/LayoutGenerator.h>
11 
12 namespace Atoms
13 {
14  class ATOMS_EXPORT DynamicLayoutGenerator : public LayoutGenerator
15  {
16  public:
17 
18  enum DynamicMode
19  {
20  kTimer = 0,
21  kTrigger
22  };
23 
25 
26  virtual ~DynamicLayoutGenerator();
27 
28  virtual std::vector<AgentInitData> generate(double time) = 0;
29 
30  virtual const char *typeName() = 0;
31 
32  bool checkGeneration(double time);
33 
34  AgentTypePtr pickAgentType();
35 
36  AgentTypePtr agentType(const int groupId, const std::string& groupIdStr) override;
37 
38  void applyOffsetToData();
39 
40  inline unsigned int dynamicGroupIdOffset() const;
41 
42  inline void setDynamicGroupIdOffset(unsigned int value);
43 
44  inline void addDynamicGroupIdOffset(unsigned int value);
45 
46  inline unsigned int dynamicMethod() const;
47 
48  inline void setDynamicMethod(unsigned int value);
49 
50  inline bool generateOnInitSimulation() const;
51 
52  inline void setGenerateOnInitSimulation(bool value);
53 
54  inline double timeToGenerate() const;
55 
56  inline void setTimeToGenerate(double value);
57 
58  inline void decreaseTimeToGenerate();
59 
60  inline bool generatorTrigger() const;
61 
62  inline void setGeneratorTrigger(bool value);
63 
64  inline bool randomizeAgentTypes() const;
65 
66  inline void setRandomizeAgentTypes(bool value);
67 
68  inline bool resetSeed() const;
69 
70  inline void setResetSeed(bool value);
71 
72  inline const std::vector<std::string>& randomAgentTypes() const;
73 
74  inline void setRandomAgentTypes(const std::vector<std::string>& value);
75 
76  inline const AtomsCore::Vector2& randomTimer() const;
77 
78  inline void setRandomTimer(const AtomsCore::Vector2& value);
79 
80  inline const std::vector<Atoms::AgentInitData>& getData() const;
81 
82  inline void setData(const std::vector<Atoms::AgentInitData>& data, bool check = false);
83 
84  protected:
85 
86  AtomsCore::Rand48 m_randDynamic;
87 
88  std::vector<std::string> m_randomAgentTypes;
89 
90  private:
91 
92  std::vector<Atoms::AgentInitData> m_data;
93 
94  AtomsCore::Vector2 m_randomTimerGenerator;
95 
96  double m_timeToGenerate;
97 
98  unsigned int m_dynamicGroupIdOffset;
99 
100  unsigned int m_dynamicMethod;
101 
102  bool m_generateOnInit;
103 
104  bool m_generatorTrigger;
105 
106  bool m_randomizeAgentTypes;
107 
108  bool m_resetSeed;
109 
110  };
111 }
112 
113 #include "DynamicLayoutGenerator.impl.h"
Definition: DynamicLayoutGenerator.h:15
virtual const char * typeName()=0
Get the type name for this generator.
AgentTypePtr agentType(const int groupId, const std::string &groupIdStr) override
Get the agent type used by this generator.
virtual std::vector< AgentInitData > generate(double time)=0
Generate a vector of agent init data.
Layout generator.
Definition: LayoutGenerator.h:31
AtomsMath::Vector2 Vector2
Vector2 class.
Definition: AtomsMath.h:54
Atoms namespace.
Definition: Agent.h:29
AtomsPtr< AgentType > AgentTypePtr
Agent type pointer.
Definition: AgentType.h:17