Hi all!
I have a class:
And I have some troubles how to write a getter and setter for my class field "groups". I did it, but I have dooubts
if it's a good way to do this. It compiles with no error but I'm a beginner in CORBA and would like get some help from anybody who is good at it. Thanks:)
I have a class:
Code:
class UserImpl : public POA_User
{
private :
typedef vector<GroupImpl*> Groups;
Groups groups;
public :
User::Groups* getGroups();
void setGroups(const ::User::Groups& g);
};
#endif
#include "UserImpl.h"
User::Groups* UserImpl::getGroups()
{
const size_t size = this->groups.size();
User::Groups_var seqOfObjects = new User::Groups(size);
seqOfObjects->length(size);
size_t i = 0;
vector<GroupImpl*>::const_iterator it = groups.begin();
while (it != groups.end())
{
seqOfObjects[i] = Group::_duplicate((*it)->_this());
++it;
++i;
}
return seqOfObjects._retn();
}
void UserImpl::setGroups(const ::User::Groups& g)
{
const size_t size = g.length();
this->groups.resize(size);
this->groups.clear();
for(size_t i = 0; i<size; i++)
{
GroupImpl *newGroup = new GroupImpl(g[i]->getID(), g[i]->getName(),
g[i]->getDescription(),g[i]->getFounder(),
*(g[i]->getUsers()));
this->groups.push_back(Groups::value_type(newGroup));
}
}
if it's a good way to do this. It compiles with no error but I'm a beginner in CORBA and would like get some help from anybody who is good at it. Thanks:)
Comment