GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
Behavior.h
1 /*
2  * GDevelop Core
3  * Copyright 2008-2016 Florian Rival ([email protected]). All rights
4  * reserved. This project is released under the MIT License.
5  */
6 #pragma once
7 
8 #include "GDCore/String.h"
9 #include "GDCore/Project/BehaviorConfigurationContainer.h"
10 #include "GDCore/Project/MemoryTrackedRegistry.h"
11 #include "GDCore/Tools/MakeUnique.h"
12 
13 namespace gd {
14 
24 class GD_CORE_API Behavior: public BehaviorConfigurationContainer {
25  public:
26 
27  Behavior(): BehaviorConfigurationContainer(), isDefaultBehavior(false) {};
28  Behavior(const gd::String& name_, const gd::String& type_)
29  : BehaviorConfigurationContainer(name_, type_),
30  isDefaultBehavior(false) {};
31  Behavior(const Behavior& other)
33  isDefaultBehavior(other.isDefaultBehavior) {};
34  Behavior& operator=(const Behavior& other) {
35  if (this != &other) {
36  BehaviorConfigurationContainer::operator=(other);
37  isDefaultBehavior = other.isDefaultBehavior;
38  }
39  return *this;
40  }
41  virtual ~Behavior();
42  virtual std::unique_ptr<gd::Behavior> Clone() const {
43  return gd::make_unique<gd::Behavior>(*this);
44  }
45 
46  bool IsDefaultBehavior() const {
47  return isDefaultBehavior;
48  }
49 
50  void SetDefaultBehavior(bool isDefaultBehavior_) {
51  isDefaultBehavior = isDefaultBehavior_;
52  }
53 
54  private:
55  gd::MemoryTracked _memoryTracked{this, "Behavior"};
56  bool isDefaultBehavior;
57 };
58 
59 } // namespace gd
Base class for containers of behavior configuration. They can be attached to objects (Behavior) or la...
Definition: BehaviorConfigurationContainer.h:35
Base class used to represents a behavior that can be applied to an object. It stores the content (i....
Definition: Behavior.h:24
A non-copyable, non-movable member object that registers/unregisters its owner with MemoryTrackedRegi...
Definition: MemoryTrackedRegistry.h:238
String represents an UTF8 encoded string.
Definition: String.h:33
Definition: CommonTools.h:24
bool GD_CORE_API IsDefaultBehavior(const gd::ObjectsContainer &project, const gd::ObjectsContainer &layout, gd::String objectOrGroupName, gd::String behaviorName, bool searchInGroups)
Check if a behavior is a default one or doesn't exist in an object or all objects of a group.
Definition: Layout.cpp:638