I'm looking at developing a networking framework somewhat styled after what Mina offers in Java.. but native and optionally scriptable through wrappers.
I've been looking at doing it in C, but there seems to be so much extra overhead while implementing data hiding, custom memory management, and some basic inheritance. I've recently done some work in C++ and got the taste of the compacting of certain management tasks into small type-safe pieces of code..... I'm hoping that when my library is in good shape that other open-source developers can consume it, however I've often seen that C++ is viewed as "evil" and avoided in any projects. Since I plan on using libev and/or libevent pieces, I figured that the project may be of the most use to subscribers of this list.... I figured I'd poll you all.... Basically the plan is to develop objects in this fashion: * C Interface w/ either publicly exposed structs, or typedefs for structs not-yet-defines. + usage functions * C++ Implementation Interface inheriting/implementing from structs in C interface * C function implementation calling the C++ implementation interface functions * C++ Implementation - actual guts Example: IoAccepter.h: struct IoAccepter { IoManager *manager; IoHandler *handler; }; IoAccepter *IoAccepter_new(IoManager *manager, IoHandler *handler); int IoAccepter_bind(IoAccepter *accepter, const struct sockaddr *addr, socklen_t addr_len); IoAccepter.hpp: class IoAccepter_impl : public IoAccepter { public: IoAccepter(IoManager *manager, IoHandler *handler); int bind(const struct sockaddr *addr, socklen_t addr_len); private: /* already-bound sockets -> addresses ... */ } /* binding layer */ extern "C" { IoAccepter *IoAccepter_new(IoManager *manager, IoHandler *handler) { return new IoAccepter_impl(manager, handler); } int IoAccepter_bind(IoAccepter *accepter, const struct sockaddr *addr, socklen_t addr_len) { return ((IoAccepter_impl*)accepter)->bind(addr, addr_len); } IoAccepter.cpp ..... deeper impl Any views on this... perhaps there's a better solution I hadn't thought of. (I've seen glib and its large set of utilities for object-orientation in C... but it seems just too large and clunky....) -- Thomas Harning Jr. _______________________________________________ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users