AWind
Environment.h
1 #pragma once
2 /*
3  AWind.h - Arduino window library support for Color TFT LCD Boards
4  Copyright (C)2014 Andrei Degtiarev. All right reserved
5 
6  You can find the latest version of the library at
7  https://github.com/AndreiDegtiarev/AWind
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the CC BY-NC-SA 3.0 license.
11  Please see the included documents for further information.
12 
13  Commercial use of this library requires you to buy a license that
14  will allow commercial use. This includes using the library,
15  modified or not, as a tool to sell products.
16 
17  The license applies to all part of the library including the
18  examples and tools supplied with the library.
19 */
20 #include "LinkedList.h"
21 #include "AHelper.h"
22 #include "Decorator.h"
23 
24 typedef LinkedList<Decorator> DecoratorList;
26 {
27 public:
28  const __FlashStringHelper *ID;
29  DecoratorList *Decorators;
30 };
33 {
34  static Environment *_singltone;
35  LinkedList<DecoratorGroupEntry> _shared_decorators;
36 
38  Environment()
39  {
40  _singltone=this;
41  }
42 public:
44  static Environment *Get()
45  {
46  if(_singltone == NULL)
47  _singltone = new Environment();
48  return _singltone;
49  }
51  void RegisterDecoratorsGroup(const __FlashStringHelper *id,DecoratorList * decorators)
52  {
54  entry->ID=id;
55  entry->Decorators=decorators;
56  _shared_decorators.Add(entry);
57  }
59  DecoratorList *FindDecorators(const __FlashStringHelper *id)
60  {
61  for(int i=0;i<_shared_decorators.Count();i++)
62  {
63  if(AHelper::compare_F(id, _shared_decorators[i]->ID))
64  return _shared_decorators[i]->Decorators;
65 
66  }
67  return NULL;
68  }
69 
70 };
static Environment * Get()
Returns singltone instance of environment.
Definition: Environment.h:44
This singltone class contains shared application resources like decorators.
Definition: Environment.h:32
Definition: Environment.h:25
void RegisterDecoratorsGroup(const __FlashStringHelper *id, DecoratorList *decorators)
Registers decorators group. It is like application resources that can be shred between windows of the...
Definition: Environment.h:51
DecoratorList * FindDecorators(const __FlashStringHelper *id)
Finds registered decorators by the name.
Definition: Environment.h:59