|
From: Chris F. <cd...@fo...> - 2012-02-22 23:58:50
|
On Wed, Feb 22, 2012 at 10:03:41AM -0800, Emanoil Kotsev wrote:
> My plan (and part of it is already coded) is to provide access to the engine via UI Api to make configuration and adjustments over the plugin possible and from the DB API for the data sync.
> How do you feel about it?
You're blazing a trail in new territory, so I would say that the code is
the important part. The more you code, the more details you'll uncover,
and eventually get to the point where it works. :-)
> Something I also do not understand from programming point of view
> I had a look into SyncEvo and there they use boosts shared pointers. So my question is under which circumstanses are you forced to do it - the name is somehow self explaining - but shared between what and why is something I don't understand
Boost shared pointers (or the shared pointers in the tr1 namespace, which
are the same), are for sharing pointers within the same application.
Smart pointers are designed so that you don't have to worry about when
to free an object. As soon as the pointer object goes out of scope, then
the object it points to is freed.
If you use std::auto_ptr<>, then only one auto_ptr object has a copy of
the pointer at a time.
auto_ptr<MyObject> ptr1 (new MyObject);
auto_ptr<MyObject> ptr2;
ptr2 = ptr1; // ptr1 is now null, and cannot be used
// only ptr2 is valid
You use auto_ptr when you only need one copy of a pointer at any given time.
Often when you're returning a pointer from a function.
auto_ptr<MyObject> FactoryFunction()
{
auto_ptr<MyObject> ptr;
// ... some hard work
return ptr;
}
With a shared_ptr, it keeps track of how many copies exist, and only frees
the real object when the last pointer disappears.
shared_ptr<MyObject> ptr1 (new MyObject);
shared_ptr<MyObject> ptr2;
ptr2 = ptr1; // both ptr1 and ptr2 are valid
So, in a real application, ptr1 might exist in one class, perhaps a list,
and ptr2 might exist in some other class. It doesn't matter which pointer
goes out of scope first. The last one to go out of scope will free the
object.
> also looking into my schedule for the future months it will take me some longer time for doing this.
That's ok. At least someone is working on it! :-)
- Chris
|