TrashBin._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: TrashBin.pike,v 1.1 2008/03/31 13:39:57 exodusd Exp $
18  */
19 inherit "/classes/Container";
20 #include <classes.h>
21 #include <macros.h>
22 #include <exception.h>
23 #include <attributes.h>
24 class TrashBin : public Container{
25 public:
26 
27 
28 
29 
30 
31 protected:
32  void
33 delete_object()
34 {
35  THROW("Cannot delete the trashbin!", E_ACCESS);
36  ::delete_object();
37 }
38 
39 public:
40 
41 void empty()
42 {
43  mixed err;
44 
45  foreach(get_inventory(), object obj) {
46  err = catch {
47  obj->delete();
48  };
49  }
50 }
51 
52 protected:
53  bool check_insert(object obj)
54 {
55  // everything goes in here !
56  return true;
57 }
58 
59 public:
60 
61 bool move(object dest)
62 {
63  if ( objectp(oEnvironment) ) {
64  // if the trashbin is inside the users inventory
65  // move it to the workroom instead (old version in inventory)
66  if ( oEnvironment->get_object_class() & CLASS_USER )
67  return ::move(oEnvironment->query_attribute(USER_WORKROOM));
68 
69  THROW("Cannot move trashbin out of users workroom !", E_ACCESS);
70  }
71 
72  return ::move(dest);
73 }
74 
75 int get_object_class() { return ::get_object_class() | CLASS_TRASHBIN; }
76 string get_identifier() { return "trashbin"; }
77 
78 
79 };