Discussion:
User containers?
yrs90
2005-04-21 00:38:32 UTC
Permalink
I'm not sure if I'm doing this right. I'd like to mediate access to the
container so that I know if data has changed, possibly to filter data sent
to views, and to provide some map-like capabilities to the vector (unique
container, named lookup).

Before I had the following

class ... {
vector<MyListItem> m_list;
};

BEGIN_ADAPTER(...)
PROP(m_list)
END_ADAPTER()

IMPLEMENT_ADAPTER_CONTAINER(vector<MyListItem>)

I tried the following:

class MyContainer : public vector<MyListItem>
{
bool IsDirty() const;
void SetDirty(const bool);

// all constructors and all modification functions
...
};

MyContainer m_list;

BEGIN_ADAPTER(MyContainer)
PROP_I(vector<MyListItem>)
PROP_RW_FUNC(IsDirty, SetDirty, "Dirty")
END_ADAPTER()

IMPLEMENT_ADAPTER_CONTAINER(vector<MyListItem>)

class ... {
MyContainer m_list;
};

BEGIN_ADAPTER(...)
PROP(m_list)
END_ADAPTER()

By the way, in order to do this I had to insert a space before the closing
bracket of the PROP_I macro to avoid >>.

Is this a valid way to proceed?

Regards,
Joel



---
[This E-mail scanned for viruses by Declude Virus]



-------------------------------------------------------
This SF.Net email is sponsored by: New Crystal Reports XI.
Version 11 adds new functionality designed to reduce time involved in
creating, integrating, and deploying reporting solutions. Free runtime info,
new features, or free trial, at: http://www.businessobjects.com/devxi/728
Hajo Kirchhoff
2005-04-21 07:14:32 UTC
Permalink
Post by yrs90
I'm not sure if I'm doing this right. I'd like to mediate access to the
container so that I know if data has changed, possibly to filter data sent
to views, and to provide some map-like capabilities to the vector (unique
container, named lookup).
BEGIN_ADAPTER(MyContainer)
PROP_I(vector<MyListItem>)
PROP_RW_FUNC(IsDirty, SetDirty, "Dirty")
END_ADAPTER()
IMPLEMENT_ADAPTER_CONTAINER(vector<MyListItem>)
class ... {
MyContainer m_list;
};
BEGIN_ADAPTER(...)
PROP(m_list)
END_ADAPTER()
This should work, as far as I can see from studying the
IMPLEMENT_ADAPTER_CONTAINER define. This define inserts code for a
get_prop_type(const vector<MyListItem>*) function and if you pass a
MyContainer object to it, the compiler should automatically cast this to
vector<MyListItem>.
Post by yrs90
By the way, in order to do this I had to insert a space before the closing
bracket of the PROP_I macro to avoid >>.
Fixed now, thanks. I'll check it in.

Hajo



-------------------------------------------------------
This SF.Net email is sponsored by: New Crystal Reports XI.
Version 11 adds new functionality designed to reduce time involved in
creating, integrating, and deploying reporting solutions. Free runtime info,
new features, or free trial, at: http://www.businessobjects.com/devxi/728
Loading...