int clsyncmgr_watchdir_add(clsyncmgr_t *ctx_p, const char *const watchdir) { char **watchdir_pp = dynamic_add(&ctx_p->watchdirs); *watchdir_pp = strdup(watchdir); return 0; }
int clsyncmgr_socketpath_add(clsyncmgr_t *ctx_p, const char *const socketpath) { char **socketpath_pp = dynamic_add(&ctx_p->socketpaths); *socketpath_pp = strdup(socketpath); return 0; }
int main() { // add. step <3/3> dynamic_add(MyLogic); DynamicBase *obj; // get, class. of course we can get from where didn't know Mylogic class except its base class. // @see line:18 dynamic_get(std::string("Mylogic"), obj); if (obj) { // here is the point, we just know the base class. Logic. Logic *lc = (Logic*)obj; lc->do_something(); // here, -----> will call really_do_something() in Mylogic class, where we didn't know the class name. MyLogic. } // very simple, have fun. reutnr 0; }