Atoms Crowd  4.1.0
LayoutGenerator.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/Globals.h>
11 #include <AtomsCore/Globals.h>
12 #include <Atoms/AgentType.h>
13 #include <Atoms/AgentInitData.h>
14 #include <atomic>
15 
16 namespace Atoms
17 {
18  class LayoutGenerator;
19 
20  typedef AtomsPtr<LayoutGenerator> LayoutGeneratorPtr;
21 
23 
28  class ATOMS_EXPORT LayoutGenerator
29  {
30  public:
31 
33 
36  LayoutGenerator(bool isStatic = true);
37 
39  virtual ~LayoutGenerator();
40 
42  virtual bool allowMultiLayoutGenerator();
43 
45  virtual bool allowMultiple();
46 
48  virtual bool mustBeFirst();
49 
51  inline bool isStaticGenerator() const;
52 
54  inline void setAsStaticGenerator(bool value);
55 
57  virtual std::vector<AgentInitData> generate(double time) = 0;
58 
60  inline AgentTypePtr agentType();
61 
63  inline void setAgentType(AgentTypePtr aType);
64 
65  inline std::atomic<size_t>& nextFreeId();
66 
67  inline const std::atomic<size_t>& nextFreeId() const;
68 
70  inline void setName(const std::string &name);
71 
73  inline const std::string &name();
74 
76  virtual const char *typeName() = 0;
77 
79  void setGroupIdOffset(const int offset);
80 
82  const int groupIdOffset();
83 
85  inline void setOffsetPelvisHeight(bool state);
86 
88  inline void setOffsetPelvisHeightOverride(const std::map<int, bool>& value);
89 
90  protected:
91 
92  std::map<int, bool> m_offsetPelvisHeightOverride;
93 
94  bool m_offsetPelvisHeight;
95 
96  private:
97 
98  AgentTypePtr m_agentType;
99 
100  std::atomic<size_t> m_nextFreeId;
101 
102  bool m_staticGenerator;
103 
104  std::string m_name;
105 
106  int m_groupIdOffset;
107  };
108 }
109 
110 #include "LayoutGenerator.impl.h"
Atoms::LayoutGenerator::setGroupIdOffset
void setGroupIdOffset(const int offset)
Set the offset for the group ids of this layout generator.
Atoms::AgentTypePtr
AtomsPtr< AgentType > AgentTypePtr
Agent type pointer.
Definition: AgentType.h:17
Atoms::LayoutGenerator::typeName
virtual const char * typeName()=0
Get the type name for this generator.
Atoms::LayoutGenerator::mustBeFirst
virtual bool mustBeFirst()
Returns wheter this layout generator should be the first one in the stack.
Atoms::LayoutGenerator::generate
virtual std::vector< AgentInitData > generate(double time)=0
Generate a vector of agent init data.
Atoms
Atoms namespace.
Definition: Agent.h:28
Atoms::LayoutGenerator::allowMultiLayoutGenerator
virtual bool allowMultiLayoutGenerator()
Returns whether this layout generator can work in conjunction with other layout generators.
Atoms::LayoutGenerator
Layout generator.
Definition: LayoutGenerator.h:29
Atoms::LayoutGenerator::LayoutGenerator
LayoutGenerator(bool isStatic=true)
Constructor.
Atoms::LayoutGenerator::~LayoutGenerator
virtual ~LayoutGenerator()
Destructor.
Atoms::LayoutGenerator::allowMultiple
virtual bool allowMultiple()
Returns whether an Agent Group can have multiple instances of this layout generator.
Atoms::LayoutGenerator::groupIdOffset
const int groupIdOffset()
Get the offset for the group ids of this layout generator.