MFMv2.0.10
Movable Feast Machine Simulator 2.0.10
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Element_Template.h
Go to the documentation of this file.
1 /* -*- mode:C++ -*-
2  Element_Template.h Tutorial template for a new Element
3  Copyright (C) 2014 The Regents of the University of New Mexico. All rights reserved.
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
18  USA
19 */
20 
21 /* <<TEMPLATE>> Replace doxygen and license information with your element information. */
28 #ifndef ELEMENT_TEMPLATE_H /* <<TEMPLATE>> Replace header guard with your element name.*/
29 #define ELEMENT_TEMPLATE_H
30 
31 #include "Element.h"
32 #include "EventWindow.h"
33 #include "ElementTable.h"
34 #include "itype.h"
35 
36 namespace MFM
37 {
38 
39  #define TEMPLATE_VERSION 1
40 
41  template <class CC>
42  class Element_Template : public Element<CC> /* <<TEMPLATE>> Replace class name with yours */
43  {
44  // Extract short names for parameter types
45  typedef typename CC::ATOM_TYPE T;
46  typedef typename CC::PARAM_CONFIG P;
47  enum { R = P::EVENT_WINDOW_RADIUS };
48 
49  private:
50 
51  ElementParameterS32<CC> m_sampleParameter;
52 
53  /* <<TEMPLATE>> Add any configurable parameters here. */
54 
55  public:
56 
57  /* <<TEMPLATE>> Replace class name with yours. Don't forget the '<CC>'. */
58  static Element_Template<CC> THE_INSTANCE;
59 
61  : Element<CC>(MFM_UUID_FOR("Template", TEMPLATE_VERSION)),
62  /* <<TEMPLATE>> Initialize all configurable parameters here. */
63  m_sampleParameter(this, "sample", "Sample Parameter",
64  "This is the description for a sample parameter.", 1, 200, 1000, 10)
65  {
66  /* <<TEMPLATE>> Set atomic symbol and name for your element. */
68  Element<CC>::SetName("Template");
69  }
70 
71  /*
72  <<TEMPLATE>> Set how likely your element is to be moved by another element. See
73  Element.h for details.
74  */
75  virtual u32 PercentMovable(const T& you,
76  const T& me, const SPoint& offset) const
77  {
78  return 100;
79  }
80 
81  /* <<TEMPLATE>> This color will be the default rendering color for your element. */
82  virtual u32 DefaultPhysicsColor() const
83  {
84  return 0xffff00ff;
85  }
86 
87  /*
88  <<TEMPLATE>> This color will be the color rendered when your
89  element is rendered in lowlighting.
90  */
91  virtual u32 DefaultLowlightColor() const
92  {
93  return 0xff770077;
94  }
95 
96  /*
97  <<TEMPLATE>> This is a short description of your element.
98  */
99  virtual const char* GetDescription() const
100  {
101  return "Short for \"Dynamic Regulator\", This Atom controls the density of "
102  "nearby Atoms by creating RES atoms and deleting nearby atoms.";
103  }
104 
105  /*
106  <<TEMPLATE>> This method is executed every time an atom of your
107  element is chosen for an event. See the tutorial in
108  the wiki for further information.
109  */
110  virtual void Behavior(EventWindow<CC>& window) const
111  {
112  }
113  };
114 
115  /*
116  <<TEMPLATE>> Rename the class names here to the class name of your element.
117  */
118  template <class CC>
119  Element_Template<CC> Element_Template<CC>::THE_INSTANCE;
120 
121 }
122 
123 #endif /* ELEMENT_TEMPLATE_H */ /* <<TEMPLATE>> Rename the header guard to your element */
virtual u32 PercentMovable(const T &you, const T &me, const SPoint &offset) const
Definition: Element_Template.h:75
virtual u32 DefaultLowlightColor() const
Definition: Element_Template.h:91
void SetName(const char *name)
Definition: Element.h:209
void SetAtomicSymbol(const char *symbol)
Definition: Element.h:193
Definition: Parameter.h:593
Definition: Element_Template.h:42
virtual void Behavior(EventWindow< CC > &window) const
Definition: Element_Template.h:110
virtual u32 DefaultPhysicsColor() const
Definition: Element_Template.h:82
virtual const char * GetDescription() const
Definition: Element_Template.h:99
Definition: ElementTable.h:43
Definition: Atom.h:43