Otawa  0.10
Registry.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  * Registry class interface
4  *
5  * This file is part of OTAWA
6  * Copyright (c) 2005-7, IRIT UPS.
7  *
8  * OTAWA is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * OTAWA is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with OTAWA; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 #ifndef OTAWA_PROC_PROC_REGISTRY_H
23 #define OTAWA_PROC_PROC_REGISTRY_H
24 
25 #include <elm/genstruct/HashTable.h>
26 #include <elm/PreIterator.h>
28 
29 namespace otawa {
30 
31 // Registry class
32 class Registry: public Initializer<AbstractRegistration> {
33  friend class AbstractRegistration;
35 
36 public:
37  static const AbstractRegistration *find(CString name);
38 
39  // Iter class
40  class Iter: public htab_t::Iterator {
41  public:
42  inline Iter(void): htab_t::Iterator(_.procs) { }
43  };
44 
45 private:
47  static Registry _;
48  Registry(void);
49 };
50 
51 
52 // Macro
53 template <class T>
54 inline const AbstractRegistration& registration(void) { return T::__reg; }
55 
56 
57 // ConfigIter class
58 class ConfigIter: public PreIterator<ConfigIter, AbstractIdentifier *> {
59 public:
60  inline ConfigIter(const AbstractRegistration& registration, bool all = true)
61  : reg(&registration), iter(reg->configs), _all(all) { step(); }
62  inline AbstractIdentifier *item(void) const { return iter.item(); }
63  inline void next(void) { iter.next(); step(); }
64  inline bool ended(void) const { return !reg; }
65 
66 private:
67  void step(void);
70  bool _all;
71 };
72 
73 
74 // FeatureIter class
75 class FeatureIter: public PreIterator<FeatureIter, const FeatureUsage *> {
76 public:
78  : reg(&registration), iter(reg->features) { step(); }
79  inline const FeatureUsage *item(void) const { return &iter.item(); }
80  inline void next(void) { iter.next(); step(); }
81  inline bool ended(void) const { return !reg; }
82 
83 private:
84  void step(void);
87 };
88 
89 } // otawa
90 
91 #endif // OTAWA_PROC_PROC_REGISTER_H
Iterator on the features used by the processor.
Definition: Registry.h:75
void step(void)
Definition: proc_Registry.cpp:284
Registry(void)
To ensure that no other registry is built.
Definition: proc_Registry.cpp:64
Definition: Registration.h:52
bool ended(void) const
Definition: Registry.h:81
const FeatureUsage * item(void) const
Definition: Registry.h:79
Abstract class to represent the registered processors.
Definition: Registration.h:80
static Registry _
Default registry.
Definition: Registry.h:47
Class dedicated to the registering of the processors.
Definition: Registry.h:32
static const AbstractRegistration * find(CString name)
Look for a processor matching the given name.
Definition: proc_Registry.cpp:56
bool ended(void) const
Definition: Registry.h:64
const AbstractRegistration & registration(void)
Definition: Registry.h:54
AbstractIdentifier * item(void) const
Definition: Registry.h:62
Represents a unique identifier used by the annotation system.
Definition: AbstractIdentifier.h:32
FeatureIter(const AbstractRegistration &registration)
Definition: Registry.h:77
void next(void)
Definition: Registry.h:63
Iterator(const HashTable< K, T, H > &htab)
Iter(void)
Definition: Registry.h:42
SLList< AbstractIdentifier * >::Iterator iter
Definition: Registry.h:69
bool _all
Definition: Registry.h:70
genstruct::HashTable< String, const AbstractRegistration * > htab_t
Definition: Registry.h:34
Definition: PropList.h:28
const AbstractRegistration * reg
Definition: Registry.h:85
Definition: Registry.h:40
void next(void)
Definition: Registry.h:80
cstring name
Definition: odisasm.cpp:107
ConfigIter(const AbstractRegistration &registration, bool all=true)
Definition: Registry.h:60
htab_t procs
Definition: Registry.h:46
void step(void)
Definition: proc_Registry.cpp:267
Iterator on the configurations of a processor.
Definition: Registry.h:58
const AbstractRegistration * reg
Definition: Registry.h:68
SLList< FeatureUsage >::Iterator iter
Definition: Registry.h:86