This file is indexed.

/usr/include/Eris-1.3/Eris/UIFactory.h is in liberis-1.3-dev 1.3.23-6ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
#ifndef ERIS_UI_FACTORY_H
#define ERIS_UI_FACTORY_H

#include <Atlas/Message/Element.h>

#include <sigc++/object.h>
#include <sigc++/signal.h>

#include <list>

namespace Atlas {
  namespace Objects {
    namespace Operation {
      class Create;
    }
    namespace Entity {
      class UIEntity;
      class Frame;
      class Slot;
    }
  }
}

namespace Eris { namespace UI {

// Element is a virtual class because we expect to
// get an inheritance hierarchy like:
//
//              Element
//              |     |
//    FrameElement    MyElement
//              |     |
//           MyFrameElement
//
// where MyElement and MyFrameElement are classes
// in client-side bindings. There should only be
// one Element instance in MyFrameElement, so
// we want children of Element to inherit
// virtually.

/// an instantiated dialog element
class Element
{
 public:
  virtual ~Element() {}

  // implementations of this function should emit PropertiesChanged for
  // valid properties
  virtual void setProperties(const Atlas::Message::Element::MapType&) = 0;

  void setProperty(const std::string& name, const Atlas::Message::Element& arg)
  {
    Atlas::Message::Element::MapType map;
    map[name] = arg;
    setProperties(map);
  }

  SigC::Signal1<void,const Atlas::Message::Element::MapType&> PropertiesChanged;
};

class SlotElement : public Element, virtual public SigC::Object
{
 public:
  virtual void action(const Atlas::Message::Element::MapType&) = 0;
};

class FrameElement : virtual public Element
{
 public:
  ~FrameElement()
  {
    for(SlotList::iterator I = _list.begin(); I!= _list.end(); ++I)
     delete *I;
  }

  virtual void pack(Element*) = 0;
  void packSlot(SlotElement* slot) {_list.push_back(slot);}

 private:
  typedef std::list<SlotElement*> SlotList;
  SlotList _list;
};

class Bindings;

class Factory
{
 public:
  class BaseGen
  {
   public:
    virtual ~BaseGen() {}
    virtual Element* create(const Atlas::Message::Element::MapType&) = 0;
  };

  template<class E>
  class Gen : public BaseGen
  {
   public:
    virtual Element* create(const Atlas::Message::Element::MapType& attrs)
		{return E(attrs);}
  };

  Factory(const std::string& id, BaseGen* gen)
	: _id(id), _gen(gen), _persistent(true), _refcount(1)
	{_id_list.push_back(id);}
  virtual ~Factory() {if(_persistent && _gen) delete _gen;}

  typedef std::map<std::string,Element*> IDMap;

  // create a dialog element
  virtual Element* create(IDMap&) const;
  // create a new factory
  virtual Factory* parse(const Atlas::Message::Element::MapType&, const Bindings&) const;

  void ref() {++_refcount;}
  void unref() {if(--_refcount == 0) delete this;}
  bool unique() const {return _refcount == 1;}
  bool persistent() const {return _persistent;}
  const std::string& id() const {return _id;}

 protected:
  typedef std::list<std::string> IDList;

  Factory(const Atlas::Objects::Entity::UIEntity&, const std::string&,
          const IDList&, const Atlas::Message::Element::MapType&, BaseGen*);

  const Atlas::Message::Element::MapType& attrs() const {return _attrs;}
  const IDList& idlist() const {return _id_list;}
  BaseGen* gen() const {return _gen;}

 private:
  Factory(const Factory&);
  Factory& operator=(const Factory&);

  std::string _id;
  IDList _id_list; // _id plus all parent ids, for use in connecting slots
  BaseGen* _gen;
  bool _persistent; // factories not created by the server
  unsigned long _refcount;
  Atlas::Message::Element::MapType _attrs;
};

// factory for children of Atlas::Objects::Entity::Frame
class FrameFactory : public Factory
{
 public:
  class BaseGen
  {
   public:
    virtual ~BaseGen() {}
    virtual FrameElement* create(const std::string& valign,
	const std::string& halign, const std::string& rel_pos,
	const Atlas::Message::Element::MapType&) = 0;
  };
  template<class FE>
  class Gen : public BaseGen
  {
   public:
    virtual FrameElement* create(const std::string& valign,
	const std::string& halign, const std::string& rel_pos,
	const Atlas::Message::Element::MapType& attrs)
		{return new FE(valign, halign, rel_pos, attrs);}
  };


  FrameFactory(BaseGen* gen) : Factory("frame", 0), _valign("center"),
	_halign("center"), _rel_pos("right"), _gen(gen) {}
  virtual ~FrameFactory();

  virtual Element* create(IDMap&) const;
  virtual Factory* parse(const Atlas::Message::Element::MapType&, const Bindings&) const;

 private:
  FrameFactory(const Atlas::Objects::Entity::Frame&, const IDList&,
	       const Bindings&, const Atlas::Message::Element::MapType&, BaseGen*);

  std::string _valign, _halign, _rel_pos;
  typedef std::list<Factory*> ChildList;
  ChildList _children;
  BaseGen* _gen;
};

class SlotFactory : public Factory
{
 public:
  // for the base slot classes
  SlotFactory(const std::string& id, BaseGen* gen) : Factory(id, gen) {}

  virtual Element* create(IDMap&) const;
  virtual Factory* parse(const Atlas::Message::Element::MapType&, const Bindings&) const;

  const Atlas::Message::Element::ListType& target() const {return _target;}

 private:
  SlotFactory(const Atlas::Objects::Entity::Slot&, const IDList&,
	      const Atlas::Message::Element::MapType&, BaseGen*);

  Atlas::Message::Element::ListType _target;
};

/// the dialog generator/handler
class Bindings
{
 public:
  Bindings();
  virtual ~Bindings();

  void parse(const Atlas::Message::Element&);

  /// purge all server-generated classes
  void clear();

  Factory* findFactory(const Atlas::Message::Element& id) const
  {
    return id.isString() ? findFactory(id.asString()) : 0;
  }

  Factory* findFactory(const std::string& id) const
  {
    FactoryMap::const_iterator I = _factory_map.find(id);
    return (I != _factory_map.end()) ? I->second : 0;
  }

  bool bind(Factory* f) {return _factory_map.insert(
	FactoryMap::value_type(f->id(), f)).second;}

  // a trick to get reasonable syntax for the interface,
  // e.g. Bind<Foo>(bindings).slot("foo");
  template<class C>
  friend struct Bind
  {
   public:
    Bind(Bindings& b) : _b(b) {}

    bool slot(const std::string& id)
	{return _b.bind(new SlotFactory(id, new SlotFactory::Gen<C>()));}
    bool element(const std::string& id)
	{return _b.bind(new Factory(id, new Factory::Gen<C>()));}
    bool frame()
	{return _b.bind(new FrameFactory(new FrameFactory::Gen<C>()));}
   private:
    Bindings& _b;
  };

  // put an Element on the screen as a dialog
  virtual void display(Element*, const std::string& id) = 0;

  virtual void createConsoleElement(const Atlas::Objects::Entity::UIEntity&) = 0;

 private:

 typedef std::map<std::string,Factory*> FactoryMap;
 FactoryMap _factory_map;
};

}} // namespace Eris::UI

#endif