2 * Copyright (c) 2010-2012 Zmanda, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300
19 * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
22 %module "Amanda::Feature"
23 %include "amglue/amglue.swg"
24 %include "exception.i"
26 %include "Amanda/Feature.pod"
29 #include "amfeatures.h"
32 /* include the header file directly - this saves us having to remember
33 * to add new constants to both places */
34 #define AMANDA_FEATURE_SWG
35 %include "../common-src/amfeatures.h"
38 typedef am_feature_t Set;
44 am_release_feature_set(self);
46 void add(int feature) {
47 am_add_feature(self, feature);
49 void remove(int feature) {
50 am_remove_feature(self, feature);
52 int has(int feature) {
53 return am_has_feature(self, feature);
57 return am_feature_to_string(self);
62 %newobject am_string_to_feature;
63 extern Set *am_string_to_feature(char *s);
64 %newobject am_set_default_feature_set;
65 extern Set *am_set_default_feature_set(void);
66 %newobject am_init_feature_set;
67 extern Set *am_init_feature_set();
69 extern am_feature_t *am_features(Set *);
73 package Amanda::Feature::Set;
75 # this does not work, because SWIG uses the string value of objects as a hash key
76 # even after calling their destructor, which leads to a segfault.
78 # use overload '""' => sub { $_[0]->as_string(); };
80 sub Amanda::Feature::Set::from_string {
82 return Amanda::Feature::am_string_to_feature(@_);
85 sub Amanda::Feature::Set::old {
87 return Amanda::Feature::am_set_default_feature_set();
90 sub Amanda::Feature::Set::mine {
92 return Amanda::Feature::am_init_feature_set();
95 sub Amanda::Feature::Set::features {
97 return Amanmda::Feature::features();
101 package Amanda::Feature;