Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Adding merge to data value container #3134

Merged
merged 6 commits into from
Nov 14, 2018

Conversation

ddiezrod
Copy link
Contributor

@ddiezrod ddiezrod commented Oct 22, 2018

The idea is to use this method to "complete" a property from other property.

@loumalouomega loumalouomega requested review from pooyan-dadvand and a team October 22, 2018 11:53
@loumalouomega loumalouomega changed the title [core] Adding merge to data value container [Core] Adding merge to data value container Oct 22, 2018
Copy link
Member

@RiccardoRossi RiccardoRossi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this definitely needs to be discussed.

what is the expected behaviour?

@ddiezrod
Copy link
Contributor Author

ddiezrod commented Oct 22, 2018

@RiccardoRossi The idea is that I want to have a general property lets say Property 0. Then, I have a particular Property 1 that only has some specific values. I want all the property values from Property 0 to be copied into Property 1 (except if this variable already exists, then it keeps its old values.)

I tried to do this without doing any change in the core, but after discussing it with @pooyan-dadvand I did not find any other way to do it.

@maceligueta
Copy link
Member

I think that the decison of 'respecting the old value' or 'overwriting the old value' could be left to the end developer, in the form of a true/false flag or coding two different methods.

@RiccardoRossi
Copy link
Member

my point however is: does this need to be a class method?

@ddiezrod
Copy link
Contributor Author

@RiccardoRossi so.. what is your suggestion? mData is private so I do not know what else you could do...

@pooyan-dadvand
Copy link
Member

I would go for a class method as it only changes this class members with almost full cohesion.

@RiccardoRossi
Copy link
Member

ok, about the method. I'll dismiss my review since it is no longer relevant
However please do take into account the comment of @maceligueta

@RiccardoRossi RiccardoRossi dismissed their stale review October 29, 2018 09:58

no longer relevant

@philbucher
Copy link
Member

@ddiezrod please add a test before merging this

@ddiezrod
Copy link
Contributor Author

Ok, I will use a local flag as @RiccardoRossi and @maceligueta proposed. I will have to add then the corresponding .cpp file and the test for this method.

@ddiezrod
Copy link
Contributor Author

test and flag added. Please review @RiccardoRossi @pooyan-dadvand @jrubiogonzalez

@ddiezrod
Copy link
Contributor Author

ddiezrod commented Nov 7, 2018

@RiccardoRossi Can you approve now?

@ddiezrod
Copy link
Contributor Author

Anyone? @RiccardoRossi @pooyan-dadvand ?

RiccardoRossi
RiccardoRossi previously approved these changes Nov 12, 2018
for (const_iterator i = rOther.mData.begin(); i != rOther.mData.end(); ++i) {
bool variable_already_exist = false;
for (iterator j = mData.begin(); j != mData.end(); ++j) {
if (i->first->Key() == j->first->Key()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are u using the key here? i think you can use directly

    i->first == j->first


//Second case: do overwrite old values
options.Set(DataValueContainer::OVERWRITE_OLD_VALUES, true);
container_target.Merge(container_origin, options);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just as a comment, but i think you can write

  container_target.Merge(container_origin, DataValueContainer::OVERWRITE_OLD_VALUES)

@ddiezrod ddiezrod merged commit 2b32d2f into master Nov 14, 2018
@ddiezrod ddiezrod deleted the core/adding-merge-to-data-value-container branch November 14, 2018 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants