MFMv2.0.10
Movable Feast Machine Simulator 2.0.10
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Element_Xtal_General.h
Go to the documentation of this file.
1 /* -*- mode:C++ -*-
2  Element_Xtal_General.h General-purpose configurable evolvable crystal
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 
28 #ifndef ELEMENT_XTAL_GENERAL_H
29 #define ELEMENT_XTAL_GENERAL_H
30 
31 #include "Element.h"
32 #include "EventWindow.h"
33 #include "ElementTable.h"
34 #include "AbstractElement_Xtal.h"
35 #include "itype.h"
36 
37 namespace MFM
38 {
39 
40 #define ELT_VERSION 1
41 
42  template <class CC>
44  {
45  // Extract short names for parameter types
46  typedef typename CC::ATOM_TYPE T;
47  typedef typename CC::PARAM_CONFIG P;
48 
49  enum {
50  R = P::EVENT_WINDOW_RADIUS,
51  BITS = P::BITS_PER_ATOM,
52 
53  SITES = EVENT_WINDOW_SITES(R)
54  };
55 
56  typedef BitField<BitVector<BITS>, VD::BITS, SITES, BITS - SITES> AFSites;
57 
59 
60  public:
61 
62  static Element_Xtal_General THE_INSTANCE;
63  static const u32 TYPE()
64  {
65  return THE_INSTANCE.GetType();
66  }
67 
69  AbstractElement_Xtal<CC>(MFM_UUID_FOR("XtalGen", ELT_VERSION)),
70  m_neighborhood(this, "neighborhood", "Neighborhood",
71  "Newly-drawn Xg's will have this neighborhood.",0)
72  {
74  Element<CC>::SetName("General crystal");
75  }
76 
77  virtual const T & GetDefaultAtom() const
78  {
79  static T defaultAtom(TYPE(),0,0,0);
80  AFSites::WriteLong(this->GetBits(defaultAtom), m_neighborhood.GetValue());
81 
82  return defaultAtom;
83  }
84 
85  virtual u32 GetSymI(T &atom, EventWindow<CC>& window) const
86  {
87  return (u32) PSYM_NORMAL;
88  }
89 
90  virtual u32 DefaultPhysicsColor() const
91  {
92  return 0xff11bb33;
93  }
94 
95  virtual u32 DefaultLowlightColor() const
96  {
97  return 0xff0c8023;
98  }
99 
100  virtual u32 LocalPhysicsColor(const T& atom, u32 selector) const
101  {
102  return DefaultPhysicsColor();
103  }
104 
105  typedef typename MFM::AbstractElement_Xtal<CC>::XtalSites XtalSites;
106 
110  virtual bool IsSameXtal(T & self, const T & otherAtom, EventWindow<CC>& window) const
111  {
112  return
113  AFSites::ReadLong(this->GetBits(self)) == AFSites::ReadLong(this->GetBits(otherAtom));
114  }
115 
116  virtual void GetSites(T & atom, XtalSites & sites, EventWindow<CC>& window) const
117  {
118  u64 bits = AFSites::ReadLong(this->GetBits(atom));
119  sites.WriteLong(0, SITES, bits);
120  }
121 
122  };
123 
124  template <class CC>
125  Element_Xtal_General<CC> Element_Xtal_General<CC>::THE_INSTANCE;
126 
127 }
128 
129 #endif /* ELEMENT_XTAL_GENERAL_H */
u32 GetType() const
Definition: Element.h:290
virtual const T & GetDefaultAtom() const
Definition: Element_Xtal_General.h:77
void SetName(const char *name)
Definition: Element.h:209
void SetAtomicSymbol(const char *symbol)
Definition: Element.h:193
static u64 ReadLong(const BV &bv)
Definition: BitField.h:98
Definition: Element_Xtal_General.h:43
Definition: Atom.h:45
virtual u32 LocalPhysicsColor(const T &atom, u32 selector) const
Definition: Element_Xtal_General.h:100
static void WriteLong(BV &bv, u64 val)
Definition: BitField.h:192
Definition: AbstractElement_Xtal.h:40
virtual u32 DefaultLowlightColor() const
Definition: Element_Xtal_General.h:95
Definition: ElementTable.h:43
virtual bool IsSameXtal(T &self, const T &otherAtom, EventWindow< CC > &window) const
Definition: Element_Xtal_General.h:110
#define EVENT_WINDOW_SITES(radius)
Definition: MDist.h:46
const BitVector< P::BITS_PER_ATOM > & GetBits(const T &atom) const
Definition: Element.h:132
virtual u32 DefaultPhysicsColor() const
Definition: Element_Xtal_General.h:90
Definition: Parameter.h:715