Skip to content

Commit

Permalink
libdoomsday|libcore: Copying profiles and game profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jan 6, 2017
1 parent 1ecc1ae commit a5c8a86
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doomsday/apps/libdoomsday/include/doomsday/gameprofiles.h
Expand Up @@ -41,6 +41,8 @@ class LIBDOOMSDAY_PUBLIC GameProfiles : public de::Profiles
Profile(de::String const &name = de::String());
Profile(Profile const &other);

Profile &operator = (Profile const &other);

void setGame(de::String const &id);
void setPackages(de::StringList const &packagesInOrder);
void setUserCreated(bool userCreated);
Expand Down
10 changes: 10 additions & 0 deletions doomsday/apps/libdoomsday/src/gameprofiles.cpp
Expand Up @@ -166,6 +166,16 @@ GameProfiles::Profile::Profile(Profile const &other)
, d(new Impl(*other.d))
{}

GameProfiles::Profile &GameProfiles::Profile::operator = (Profile const &other)
{
AbstractProfile::operator = (other);
d->gameId = other.d->gameId;
d->packages = other.d->packages;
d->userCreated = other.d->userCreated;
d->useGameRequirements = other.d->useGameRequirements;
return *this;
}

void GameProfiles::Profile::setGame(String const &id)
{
d->gameId = id;
Expand Down
7 changes: 7 additions & 0 deletions doomsday/sdk/libcore/include/de/data/profiles.h
Expand Up @@ -51,6 +51,13 @@ class DENG2_PUBLIC Profiles

virtual ~AbstractProfile();

/**
* Assigns another profile's data to this one. The owner pointer is not copied.
* @param other Other profile.
* @return Reference.
*/
AbstractProfile &operator = (AbstractProfile const &other);

void setOwner(Profiles *owner);

Profiles &owner();
Expand Down
8 changes: 8 additions & 0 deletions doomsday/sdk/libcore/src/data/profiles.cpp
Expand Up @@ -361,6 +361,14 @@ Profiles::AbstractProfile::AbstractProfile(AbstractProfile const &profile)
Profiles::AbstractProfile::~AbstractProfile()
{}

Profiles::AbstractProfile &Profiles::AbstractProfile::operator = (AbstractProfile const &other)
{
d->name = other.d->name;
d->readOnly = other.d->readOnly;
// owner is not copied
return *this;
}

void Profiles::AbstractProfile::setOwner(Profiles *owner)
{
DENG2_ASSERT(d->owner != owner);
Expand Down

0 comments on commit a5c8a86

Please sign in to comment.