1 #ifndef ERIS_UI_FACTORY_H
2 #define ERIS_UI_FACTORY_H
4 #include <Atlas/Message/Element.h>
6 #include <sigc++/object.h>
7 #include <sigc++/signal.h>
24 namespace Eris {
namespace UI {
49 virtual void setProperties(
const Atlas::Message::Element::MapType&) = 0;
51 void setProperty(
const std::string& name,
const Atlas::Message::Element& arg)
53 Atlas::Message::Element::MapType map;
58 SigC::Signal1<void,const Atlas::Message::Element::MapType&> PropertiesChanged;
64 virtual void action(
const Atlas::Message::Element::MapType&) = 0;
72 for(SlotList::iterator I = _list.begin(); I!= _list.end(); ++I)
76 virtual void pack(
Element*) = 0;
77 void packSlot(
SlotElement* slot) {_list.push_back(slot);}
80 typedef std::list<SlotElement*> SlotList;
93 virtual Element* create(
const Atlas::Message::Element::MapType&) = 0;
100 virtual Element* create(
const Atlas::Message::Element::MapType& attrs)
105 : _id(id), _gen(gen), _persistent(true), _refcount(1)
106 {_id_list.push_back(
id);}
107 virtual ~
Factory() {
if(_persistent && _gen)
delete _gen;}
109 typedef std::map<std::string,Element*> IDMap;
112 virtual Element* create(IDMap&)
const;
114 virtual Factory* parse(
const Atlas::Message::Element::MapType&,
const Bindings&)
const;
116 void ref() {++_refcount;}
117 void unref() {
if(--_refcount == 0)
delete this;}
118 bool unique()
const {
return _refcount == 1;}
119 bool persistent()
const {
return _persistent;}
120 const std::string& id()
const {
return _id;}
123 typedef std::list<std::string> IDList;
125 Factory(
const Atlas::Objects::Entity::UIEntity&,
const std::string&,
126 const IDList&,
const Atlas::Message::Element::MapType&, BaseGen*);
128 const Atlas::Message::Element::MapType& attrs()
const {
return _attrs;}
129 const IDList& idlist()
const {
return _id_list;}
130 BaseGen* gen()
const {
return _gen;}
133 Factory(
const Factory&);
134 Factory& operator=(
const Factory&);
140 unsigned long _refcount;
141 Atlas::Message::Element::MapType _attrs;
153 const std::string& halign,
const std::string& rel_pos,
154 const Atlas::Message::Element::MapType&) = 0;
161 const std::string& halign,
const std::string& rel_pos,
162 const Atlas::Message::Element::MapType& attrs)
163 {
return new FE(valign, halign, rel_pos, attrs);}
168 _halign(
"center"), _rel_pos(
"right"), _gen(gen) {}
171 virtual Element* create(IDMap&)
const;
172 virtual Factory* parse(
const Atlas::Message::Element::MapType&,
const Bindings&)
const;
175 FrameFactory(
const Atlas::Objects::Entity::Frame&,
const IDList&,
176 const Bindings&,
const Atlas::Message::Element::MapType&, BaseGen*);
178 std::string _valign, _halign, _rel_pos;
179 typedef std::list<Factory*> ChildList;
190 virtual Element* create(IDMap&)
const;
191 virtual Factory* parse(
const Atlas::Message::Element::MapType&,
const Bindings&)
const;
193 const Atlas::Message::Element::ListType& target()
const {
return _target;}
196 SlotFactory(
const Atlas::Objects::Entity::Slot&,
const IDList&,
197 const Atlas::Message::Element::MapType&,
BaseGen*);
199 Atlas::Message::Element::ListType _target;
209 void parse(
const Atlas::Message::Element&);
214 Factory* findFactory(
const Atlas::Message::Element&
id)
const
216 return id.isString() ? findFactory(
id.asString()) : 0;
219 Factory* findFactory(
const std::string&
id)
const
221 FactoryMap::const_iterator I = _factory_map.find(
id);
222 return (I != _factory_map.end()) ? I->second : 0;
225 bool bind(
Factory* f) {
return _factory_map.insert(
226 FactoryMap::value_type(f->id(), f)).second;}
236 bool slot(
const std::string&
id)
238 bool element(
const std::string&
id)
247 virtual void display(
Element*,
const std::string&
id) = 0;
249 virtual void createConsoleElement(
const Atlas::Objects::Entity::UIEntity&) = 0;
253 typedef std::map<std::string,Factory*> FactoryMap;
254 FactoryMap _factory_map;
Definition: UIFactory.h:67
Definition: UIFactory.h:184
Factory is used to allow custom entity creation by client libraries.
Definition: Factory.h:14
void clear()
purge all server-generated classes
Definition: UIFactory.h:145
the dialog generator/handler
Definition: UIFactory.h:203
Definition: UIFactory.h:148
Definition: UIFactory.h:89
Definition: UIFactory.h:61
Definition: UIFactory.h:97
an instantiated dialog element
Definition: UIFactory.h:42
Definition: UIFactory.h:86
Definition: UIFactory.h:157