DrawingFactory._pike
Go to the documentation of this file.
1 /* Copyright (C) 2000-2004 Thomas Bopp, Thorsten Hampel, Ludger Merkens
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * $Id: DrawingFactory.pike,v 1.1 2008/03/31 13:39:57 exodusd Exp $
18  */
19 inherit "ObjectFactory";
20 #include <classes.h>
21 #include <macros.h>
22 #include <events.h>
23 #include <access.h>
24 #include <database.h>
25 #include <attributes.h>
26 #include <types.h>
27 class DrawingFactory : public ObjectFactory{
28 public:
29 
30 
31 
32 
33 
34 protected:
35  void
36 create_object()
37 {
38  ::create_object();
39 private:
40  init_class_attribute(DRAWING_TYPE, CMD_TYPE_INT, "type",
41  0, EVENT_ATTRIBUTES_CHANGE, 0,
42  CONTROL_ATTR_CLIENT, 0);
43 private:
44  init_class_attribute(DRAWING_WIDTH, CMD_TYPE_FLOAT, "width",
45  0, EVENT_ARRANGE_OBJECT, 0,
46  CONTROL_ATTR_CLIENT, 0.0);
47 private:
48  init_class_attribute(DRAWING_HEIGHT, CMD_TYPE_FLOAT, "height",
49  0, EVENT_ARRANGE_OBJECT, 0,
50  CONTROL_ATTR_CLIENT, 0.0);
51 private:
52  init_class_attribute(DRAWING_COLOR, CMD_TYPE_INT, "color",
53  0, EVENT_ARRANGE_OBJECT, 0,
54  CONTROL_ATTR_CLIENT, 0);
55 private:
56  init_class_attribute(DRAWING_THICKNESS, CMD_TYPE_INT, "thickness",
57  0, EVENT_ARRANGE_OBJECT, 0,
58  CONTROL_ATTR_CLIENT, 0);
59 private:
60  init_class_attribute(DRAWING_FILLED, CMD_TYPE_INT, "filled",
61  0, EVENT_ARRANGE_OBJECT, 0,
62  CONTROL_ATTR_CLIENT, 0);
63 
64 }
65 
66 object execute(mapping vars)
67 {
68  object obj;
69  string name = vars["name"];
70 
71  try_event(EVENT_EXECUTE, CALLER, obj);
72  if ( vars->transient ) {
73  if ( mappingp(vars->attributes) )
74  vars->attributes[OBJ_TEMP] = 1;
75  else
76  vars->attributes = ([ OBJ_TEMP : 1 ]);
77  }
78 
79  obj = ::object_create(name, CLASS_NAME_DRAWING, 0,
80  vars["attributes"],
81  vars["attributesAcquired"],
82  vars["attributesLocked"],
83  vars["sanction"],
84  vars["sanctionMeta"]);
85  function obj_set_attribute = obj->get_function("do_set_attribute");
86  function obj_lock_attribute = obj->get_function("do_lock_attribute");
87  obj_set_attribute(DRAWING_TYPE, (int)vars["type"]);
88  obj_lock_attribute(DRAWING_TYPE);
89 
90  run_event(EVENT_EXECUTE, CALLER, obj);
91  return obj;
92 }
93 
94 public:
95 
96 string get_identifier() { return "Drawing.factory"; }
97 string get_class_name() { return "Drawing"; }
98 int get_class_id() { return CLASS_DRAWING; }
99 
100 void test () {
101 }
102 
103 
104 };