2 * Copyright (c) 2010 Zmanda, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published
6 * by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 * Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300
18 * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
21 %module "Amanda::Feature"
22 %include "amglue/amglue.swg"
23 %include "exception.i"
25 %include "Amanda/Feature.pod"
28 #include "amfeatures.h"
31 /* include the header file directly - this saves us having to remember
32 * to add new constants to both places */
33 #define AMANDA_FEATURE_SWG
34 %include "../common-src/amfeatures.h"
37 typedef am_feature_t Set;
43 am_release_feature_set(self);
45 void add(int feature) {
46 am_add_feature(self, feature);
48 void remove(int feature) {
49 am_remove_feature(self, feature);
51 int has(int feature) {
52 return am_has_feature(self, feature);
56 return am_feature_to_string(self);
61 %newobject am_string_to_feature;
62 extern Set *am_string_to_feature(char *s);
63 %newobject am_set_default_feature_set;
64 extern Set *am_set_default_feature_set(void);
65 %newobject am_init_feature_set;
66 extern Set *am_init_feature_set();
68 extern am_feature_t *am_features(Set *);
72 package Amanda::Feature::Set;
74 # this does not work, because SWIG uses the string value of objects as a hash key
75 # even after calling their destructor, which leads to a segfault.
77 # use overload '""' => sub { $_[0]->as_string(); };
79 sub Amanda::Feature::Set::from_string {
81 return Amanda::Feature::am_string_to_feature(@_);
84 sub Amanda::Feature::Set::old {
86 return Amanda::Feature::am_set_default_feature_set();
89 sub Amanda::Feature::Set::mine {
91 return Amanda::Feature::am_init_feature_set();
94 sub Amanda::Feature::Set::features {
96 return Amanmda::Feature::features();
100 package Amanda::Feature;