66 extern std::vector<std::string> PluginLibs;
67 extern std::vector<std::string> PluginActions;
68 extern std::map<std::string, std::vector <std::string> > PluginArgs;
71 void processPluginCommandLine(std::vector<std::string>& input_argv);
73 int obtainAndExecuteActions(
SgProject* n);
81 virtual bool ParseArgs(
const std::vector<std::string> &arg) {
return true; };
90 template <
typename IteratorT>
92 IteratorT begin_iterator, end_iterator;
97 template <
typename Container>
100 : begin_iterator(c.begin()), end_iterator(c.end()) {}
102 : begin_iterator(begin_iterator),
103 end_iterator(end_iterator) {}
105 IteratorT begin()
const {
return begin_iterator; }
106 IteratorT end()
const {
return end_iterator; }
117 template <
typename T> iterator_range<T>
make_range(std::pair<T, T> p) {
118 return iterator_range<T>(p.first, p.second);
122 iterator_range<decltype(begin(std::declval<T>()))> drop_begin(T &&t,
int n) {
123 return make_range(std::next(begin(t), n), end(t));
129 template <
typename T>
131 const char *Name, *Desc;
136 : Name(N), Desc(D), Ctor(C)
139 const char *getName()
const {
return Name; }
140 const char *getDesc()
const {
return Desc; }
141 T* instantiate()
const {
return Ctor(); }
147 template <
typename T>
157 static const char *
nameof(
const entry &Entry) {
return Entry.getName(); }
158 static const char *descof(
const entry &Entry) {
return Entry.getDesc(); }
164 template <
typename T,
typename U = RegistryTraits<T> >
168 typedef typename U::entry entry;
178 static void Announce(
const entry &E) {
179 for (
listener *Cur = ListenerHead; Cur; Cur = Cur->Next)
184 static node *Head, *Tail;
187 static listener *ListenerHead, *ListenerTail;
199 node(
const entry& V) : Next(NULL), Val(V) {
218 bool operator==(
const iterator &That)
const {
return Cur == That.Cur; }
219 bool operator!=(
const iterator &That)
const {
return Cur != That.Cur; }
220 iterator &operator++() { Cur = Cur->Next;
return *
this; }
221 const entry &operator*()
const {
return Cur->Val; }
222 const entry *operator->()
const {
return &Cur->Val; }
226 static iterator end() {
return iterator(NULL); }
228 static iterator_range<iterator> entries() {
251 friend void Registry::Announce(
const entry &E);
261 for (
iterator I = begin(), E = end(); I != E; ++I)
266 listener() : Prev(ListenerTail), Next(NULL) {
274 virtual ~listener() {
302 template <
typename V>
307 static T* CtorFn() {
return new V(); }
310 Add(
const char *Name,
const char *Desc)
311 : Entry(Name, Desc, CtorFn), Node(Entry) {}
320 template <
typename T,
typename U>
323 template <
typename T,
typename U>
326 template <
typename T,
typename U>
329 template <
typename T,
typename U>
virtual bool ParseArgs(const std::vector< std::string > &arg)
Parse the given plugin command line arguments.
Traits for registry entries.
static const char * nameof(const entry &Entry)
nameof/descof - Accessors for name and description of entries. These are
A static registration template.
Iterators for registry entries.
Abstract base class for registry listeners, which are informed when new entries are added to the regi...
virtual void registered(const entry &)=0
Called when an entry is added to the registry.
void init()
Calls 'registered' for each pre-existing entry.
Node in linked list of entries.
A global registry used in conjunction with static constructors to make pluggable components (like tar...
A simple registry entry which provides only a name, description, and no-argument constructor.
A range adaptor for a pair of iterators.
This class represents a source project, with a list of SgFile objects and global information about th...
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.