c# - Best way to write C ++/CLI nested object accessors -
here situation:
i have unmanaged library written in c/c++ , access functions , structures in clr, having trouble writing basic accessors nested objects. here example of how these structs laid out in libraries:
struct myobjectunmanaged { surfaceunmanaged s; ... } struct surfaceunmanaged { int numpoints; double *gridz; .... } myobjectunmanaged has multiple structures nested within, , structs surfaceunmanaged have nested objects. user needs able allocate memory these structures.
in unmanaged library, user creates instance of myobjectunmanaged , modifies each of necessary members hand. user accesses members of nested objects , sets values well. finally, pointer instance of myobjectunmanaged passed static function again modified.
here managed wrapper myobjectunmanaged
public ref class myobjectwrappermanaged { private: myobjectunmanaged *o public: myobjectwrappermanaged(){ o = new myobjectunmanaged();} // how should write accessors,properties // or functions modify objects nested within o? void setnumpointsforsurface(int numpts); // accessors seem inefficient , // gratiutous if there // lot of members access , modify } should creating managed wrappers surfaceunmanaged? if so, public members of myobjectwrappermanaged or properties , accessors return new instances of hypothetical surfacemanaged class? best way client access surfaceunmanaged allocate memory top level?
Comments
Post a Comment