MFMv2.0.10
Movable Feast Machine Simulator 2.0.10
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StaticLoader.h
Go to the documentation of this file.
1 /* -*- mode:C++ -*-
2  StaticLoader.h Element type assignment system
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 
27 #ifndef STATICLOADER_H
28 #define STATICLOADER_H
29 
30 #include "itype.h"
31 #include "Fail.h"
32 #include "UUID.h"
33 
34 namespace MFM
35 {
57  template <class CC, u32 BITS>
58  class StaticLoader {
59  static u32 m_counter;
60  static const u32 SLOTS = 1<<BITS;
61  static const UUID *(m_uuids[SLOTS]);
62  static u32 NextType() ;
63 
64  public:
65  static u32 AllocateType(const UUID & forUUID) ;
66 
71  static s32 TypeFromUUID(const UUID & forUUID) ;
72 
78  static s32 TypeFromCompatibleUUID(const UUID & forUUID) ;
79 
84  static const UUID * UUIDOfType(u32 type) {
85  if (type < 0 || type >= SLOTS)
86  return 0;
87  return m_uuids[type];
88  }
89 
90  };
91  //typedef StaticLoader<16> U16StaticLoader;
92 }
93 
94 #include "StaticLoader.tcc"
95 
96 #endif /* STATICLOADER_H */
static s32 TypeFromUUID(const UUID &forUUID)
Definition: StaticLoader.tcc:56
static s32 TypeFromCompatibleUUID(const UUID &forUUID)
Definition: StaticLoader.tcc:66
static const UUID * UUIDOfType(u32 type)
Definition: StaticLoader.h:84
Definition: UUID.h:44
Definition: StaticLoader.h:58