@@ -55,13 +55,15 @@ static void on_exit() {
55
55
}
56
56
57
57
#define GETTER (type, class, name ) static_cast <type(class ::*)()const >(&class ::name)
58
+ #define FILTER (type, class, filt, name ) static_cast <type(class ::*)(filt)const >(&class ::name)
58
59
#define SETTER (type, class, name ) static_cast <void (class ::*)(type)>(&class ::name)
60
+ #define REMOVER (type, class, name ) static_cast <bool (class ::*)(const std::string&)>(&class ::name)
59
61
#define GETBYSTR (type, class, name ) static_cast <type(class ::*)(const std::string &)const >(&class ::name)
60
62
#define GETCONTENT (type, class, name ) static_cast <type(class ::*)()const >(&class ::name)
61
- # define GETSOURCES ( base__ ) static_cast <std::vector<nix::Source>(nix::base::EntityWithSources<nix::base::base__>::*)(std::function< bool ( const nix::Source &)>) const >(&nix::base::EntityWithSources<nix::base::base__>::sources)
62
- // required to open nix::Section from DataArray, normal GETCONTENT leads to a compiler error with Visual Studio 12
63
- #define GETMETADATA ( base__ ) static_cast <nix::Section (nix::base::EntityWithMetadata <nix::base::base__ >::*)() const >(&nix::base::EntityWithMetadata <nix::base::base__ >::metadata )
64
- # define REMOVER ( type, class, name ) static_cast < bool ( class ::*)( const std::string&)>(& class ::name)
63
+
64
+ // required to operate on DataArray, Visual Studio 12 compiler does not resolve multiple inheritance properly
65
+ #define IDATAARRAY ( type, iface, attr, name, isconst ) static_cast <type (nix::base::iface <nix::base::IDataArray >::*)(attr)isconst >(&nix::base::iface <nix::base::IDataArray >::name )
66
+
65
67
66
68
// main entry point
67
69
void mexFunction (int nlhs,
@@ -127,12 +129,11 @@ void mexFunction(int nlhs,
127
129
128
130
classdef<nix::DataArray>(" DataArray" , methods)
129
131
.desc (&nixdataarray::describe)
130
- .reg (" sources" , GETSOURCES (IDataArray))
131
- .reg (" openMetadataSection" , GETMETADATA (IDataArray))
132
- // the following setter lead to an error
133
- // .reg("set_type", SETTER(const std::string&, nix::DataArray, type))
134
- // .reg("set_definition", SETTER(const std::string&, nix::DataArray, definition))
135
- // .reg("set_none_definition", SETTER(const boost::none_t, nix::DataArray, definition))
132
+ .reg (" sources" , IDATAARRAY (std::vector<nix::Source>, EntityWithSources, std::function<bool (const nix::Source &)>, sources, const ))
133
+ .reg (" openMetadataSection" , IDATAARRAY (nix::Section, EntityWithMetadata, , metadata, const ))
134
+ .reg (" set_type" , IDATAARRAY (void , NamedEntity, const std::string&, type,))
135
+ .reg (" set_definition" , IDATAARRAY (void , NamedEntity, const std::string&, definition, ))
136
+ .reg (" set_none_definition" , IDATAARRAY (void , NamedEntity, const boost::none_t , definition, ))
136
137
.reg (" set_label" , SETTER (const std::string&, nix::DataArray, label))
137
138
.reg (" set_none_label" , SETTER (const boost::none_t , nix::DataArray, label))
138
139
.reg (" set_unit" , SETTER (const std::string&, nix::DataArray, unit))
@@ -158,7 +159,7 @@ void mexFunction(int nlhs,
158
159
.desc (&nixtag::describe)
159
160
.reg (" references" , GETTER (std::vector<nix::DataArray>, nix::Tag, references))
160
161
.reg (" features" , &nix::Tag::features)
161
- .reg (" sources" , GETSOURCES (ITag ))
162
+ .reg (" sources" , FILTER (std::vector<nix::Source>, nix::Tag, std::function< bool ( const nix::Source &)>, sources ))
162
163
.reg (" openReferenceDataArray" , GETBYSTR (nix::DataArray, nix::Tag, getReference))
163
164
.reg (" openFeature" , GETBYSTR (nix::Feature, nix::Tag, getFeature))
164
165
.reg (" openSource" , GETBYSTR (nix::Source, nix::Tag, getSource))
@@ -176,7 +177,7 @@ void mexFunction(int nlhs,
176
177
.desc (&nixmultitag::describe)
177
178
.reg (" references" , GETTER (std::vector<nix::DataArray>, nix::MultiTag, references))
178
179
.reg (" features" , &nix::MultiTag::features)
179
- .reg (" sources" , GETSOURCES (IMultiTag ))
180
+ .reg (" sources" , FILTER (std::vector<nix::Source>, nix::MultiTag, std::function< bool ( const nix::Source &)>, sources ))
180
181
.reg (" hasPositions" , GETCONTENT (bool , nix::MultiTag, hasPositions))
181
182
.reg (" openPositions" , GETCONTENT (nix::DataArray, nix::MultiTag, positions))
182
183
.reg (" openExtents" , GETCONTENT (nix::DataArray, nix::MultiTag, extents))
0 commit comments