~ubuntu-branches/ubuntu/hardy/steam/hardy

« back to all changes in this revision

Viewing changes to server/factories/BugFactory.pike

  • Committer: Bazaar Package Importer
  • Author(s): Alain Schroeder
  • Date: 2006-11-21 16:03:12 UTC
  • mfrom: (2.1.4 feisty)
  • Revision ID: james.westby@ubuntu.com-20061121160312-nf96y6nihzsyd2uv
Tags: 2.2.31-3
Add patch to prevent inconsistent data after shutdown.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000-2004  Thomas Bopp, Thorsten Hampel, Ludger Merkens
2
 
 * Copyright (C) 2003-2004  Martin Baehr
3
 
 *
4
 
 *  This program is free software; you can redistribute it and/or modify
5
 
 *  it under the terms of the GNU General Public License as published by
6
 
 *  the Free Software Foundation; either version 2 of the License, or
7
 
 *  (at your option) any later version.
8
 
 *
9
 
 *  This program is distributed in the hope that it will be useful,
10
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
 *  GNU General Public License for more details.
13
 
 *
14
 
 *  You should have received a copy of the GNU General Public License
15
 
 *  along with this program; if not, write to the Free Software
16
 
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
 
 * 
18
 
 * $Id: BugFactory.pike,v 1.1.1.1 2005/02/23 14:47:21 cvs Exp $
19
 
 */
20
 
 
21
 
constant cvs_version="$Id: BugFactory.pike,v 1.1.1.1 2005/02/23 14:47:21 cvs Exp $";
22
 
 
23
 
inherit "/factories/ObjectFactory";
24
 
 
25
 
#include <classes.h>
26
 
#include <macros.h>
27
 
#include <events.h>
28
 
#include <access.h>
29
 
#include <database.h>
30
 
#include <attributes.h>
31
 
 
32
 
#include <types.h>
33
 
 
34
 
/**
35
 
 * The execute function - create a new instance of type "Bug"
36
 
 *  
37
 
 * @param mapping vars - variables like name and description
38
 
 *                'name' - the name
39
 
 *                'attributes' - default attributes
40
 
 * @return the newly created object
41
 
 * @author <a href="mailto:astra@upb.de">Thomas Bopp</a>) 
42
 
 */
43
 
object execute(mapping vars)
44
 
{
45
 
    object obj;
46
 
 
47
 
    string name = vars["name"];
48
 
    try_event(EVENT_EXECUTE, CALLER, obj);
49
 
    obj = ::object_create(name, get_class_name(), 0, 
50
 
                          vars["attributes"], vars["attributesAcquired"],
51
 
                          vars["attributesLocked"]);
52
 
    if ( stringp(vars["description"]) )
53
 
        obj->set_attribute(OBJ_DESC, vars["description"]);
54
 
    run_event(EVENT_EXECUTE, CALLER, obj);
55
 
    return obj->this();
56
 
}
57
 
 
58
 
static void create_object()
59
 
{
60
 
    ::create_object();
61
 
    init_class_attribute("status", CMD_TYPE_STRING, "bug status",
62
 
                             0, EVENT_ATTRIBUTES_CHANGE,0,
63
 
                             CONTROL_ATTR_SERVER, "new" );
64
 
}
65
 
 
66
 
static void init_factory()
67
 
{
68
 
   ::init_factory();         // Calling the parent function.
69
 
   // new attributes could be registered here too
70
 
   init_class_attribute("status", CMD_TYPE_STRING, "bug status",
71
 
                        0, EVENT_ATTRIBUTES_CHANGE,0,
72
 
                        CONTROL_ATTR_SERVER, "new" );
73
 
   
74
 
}
75
 
 
76
 
string get_identifier() { return "Bug.factory"; }
77
 
string get_class_name() { return "Bug"; }
78
 
int get_class_id() { return CLASS_BUG; }