1 /* Copyright (C) 2000-2004 Thomas Bopp, Thorsten Hampel, Ludger Merkens
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.
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.
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
17 * $Id: module.pike,v 1.1 2008/03/31 13:39:57 exodusd Exp $
19 inherit "/classes/Object";
23 #include <exception.h>
24 #include <attributes.h>
26 class module : public Object{
35 void install_module() { }
39 void create_module() {}
43 void load_module() { }
46 bool check_swap() { return false; }
50 * Callback function to initialize a module. This will call init_module()
65 * init_module is called by the Server when starting or when a package is
77 * Called from _Server when loading is finished.
88 void post_load_module()
93 mapping read_config(string cdata, string roottag)
95 return Module.read_config(cdata, roottag);
101 * Called after all modules and factories are loaded at startup
102 * or right after the package has been installed. This way the function
103 * might use factories for installation for example. The server has
104 * basically started at this point.
107 void runtime_install()
109 if ( CALLER != _Server && !(CALLER->get_object_class() & CLASS_PACKAGE) )
118 * @param string|object id - the related id.
122 create_object(string|object id)
124 do_set_attribute(OBJ_CREATION_TIME, time());
131 * Create a duplicate of the module, which will fail in this case.
132 * The function was only overriden to prevent duplication of modules.
134 * @return throws an error.
136 final object duplicate()
138 THROW("Modules cannot be duplicated!", E_ERROR);
143 * return the object class for global objets "0"
145 * @return the object class
147 int get_object_class()
149 return CLASS_MODULE | ::get_object_class();
154 * Add a global event. This will only call the server object to
155 * listen to the appropriate events. This is basic functionality of a
156 * module. Register the event-callback function.
158 * @param int event - the event to subscribe to
159 * @param function cb - the callback function to be called
160 * @param int phase - the phase: blocking or notification
163 void add_global_event(int event, function cb, int phase)
165 _Server->add_global_event(event, cb, phase);
171 * Remove all subscribed global events.
173 * @see add_global_event
176 void remove_global_events()
178 _Server->remove_global_events();
184 * This function is called when an attribute is changed in the object,
185 * that acquires an attribute from this object.
187 * @param object o - the object where an attribute was changed
188 * @param key - the key of the attribute
189 * @param val - the new value of the attribute
190 * @return false will make the acquire set to none in the calling object
192 bool keep_acquire(object o, mixed key, mixed val)
194 return true; // should still acquire from module
202 try_event( EVENT_DELETE, CALLER );
211 // do not run the default Object test