CalendarFactory._pike
Go to the documentation of this file.
1 /* Copyright (C) 2000-2003 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 inherit "/factories/RoomFactory";
18 #include <macros.h>
19 #include <classes.h>
20 #include <access.h>
21 #include <database.h>
22 #include <events.h>
23 #include <attributes.h>
24 #include <types.h>
25 class CalendarFactory : public RoomFactory{
26 public:
27 
28 
29 
30 private:
31  void init_factory()
32 {
33  ::init_factory();
34 private:
35  init_class_attribute(CALENDAR_TIMETABLE_START, CMD_TYPE_INT,
36  "timetable start", 0,
37  EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER, 8*60);
38 private:
39  init_class_attribute(CALENDAR_TIMETABLE_END, CMD_TYPE_INT,
40  "timetable end", 0,
41  EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER, 18*60);
42 private:
43  init_class_attribute(CALENDAR_TIMETABLE_ROTATION, CMD_TYPE_INT,
44  "timetable rotation", 0,
45  EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER, 60);
46 private:
47  init_class_attribute(CALENDAR_DATE_TYPE, CMD_TYPE_MAPPING,
48  "calendar date type", 0,
49  EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER, ([ ]));
50 private:
51  init_class_attribute(CALENDAR_TRASH, CMD_TYPE_OBJECT,
52  "calendar trash", 0,
53  EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER, 0);
54 private:
55  init_class_attribute(CALENDAR_STORAGE, CMD_TYPE_OBJECT,
56  "calendar storage", 0,
57  EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER, 0);
58 private:
59  init_class_attribute(CALENDAR_OWNER, CMD_TYPE_OBJECT,
60  "calendar owner", 0,
61  EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER, 0);
62 }
63 
64 object execute(mapping vars)
65 {
66  object obj;
67  try_event(EVENT_EXECUTE, CALLER, obj);
68  if ( vars->transient ) {
69  if ( mappingp(vars->attributes) )
70  vars->attributes[OBJ_TEMP] = 1;
71  else
72  vars->attributes = ([ OBJ_TEMP : 1 ]);
73  }
74 
75  obj = ::object_create(vars["name"], CLASS_NAME_CALENDAR, 0,
76  vars["attributes"],
77  vars["attributesAcquired"],
78  vars["attributesLocked"],
79  vars["sanction"],
80  vars["sanctionMeta"]);
81 
82  object factory = _Server->get_factory(CLASS_TRASHBIN);
83  object trashbin = factory->execute((["name":"trashbin", ]));
84  function do_set_attribute = obj->get_function("do_set_attribute");
85  do_set_attribute(CALENDAR_TRASH, trashbin);
86 
87  run_event(EVENT_EXECUTE, CALLER, obj);
88 }
89 
90 public:
91 
92 string get_identifier() { return "Calendar.factory"; }
93 string get_class_name() { return CLASS_NAME_CALENDAR;}
94 int get_class_id() { return CLASS_CALENDAR; }
95 
96 void test () {
97 }
98 
99 
100 };