# Update two dependent itk::DataObject

**URL:** https://discourse.itk.org/t/update-two-dependent-itk-dataobject/3269
**Category:** Beginner Questions
**Tags:** dataobject
**Created:** [July 6, 2020, 7:48pm UTC](https://discourse.itk.org/t/update-two-dependent-itk-dataobject/3269 "2020-07-06T19:48:34Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Come](https://discourse.itk.org/letter_avatar_proxy/v4/letter/c/9f8e36/32.png) [@Come](https://discourse.itk.org/u/Come)
#### Post date: [July 6, 2020, 7:48pm UTC](https://discourse.itk.org/t/update-two-dependent-itk-dataobject/3269/1 "2020-07-06T19:48:34Z")

</div>

Hi,

I created two `itk::DataObject` that are dependent and I would like to update both of them when any of the two is modified. I wonder if there is an easy way to do that (i.e. send a notification, from a `DataObject`, to another one that needs to be updated, or something similar)?  
I think the `UpdateTime` might help me there since I can compare the last time they both have been updated but not sure it’s the best idea.

Thanks!  
Côme

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [July 6, 2020, 9:20pm UTC](https://discourse.itk.org/t/update-two-dependent-itk-dataobject/3269/2 "2020-07-06T21:20:20Z")

</div>

[AddObserver](https://itk.org/Doxygen/html/classitk_1_1Object.html#a23703e82fa4a979fd512528f471606a0) method comes to mind, but I don’t know whether there is a `Modified` event.

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [July 6, 2020, 9:45pm UTC](https://discourse.itk.org/t/update-two-dependent-itk-dataobject/3269/3 "2020-07-06T21:45:09Z")

</div>

As described, I would overload both the `itk::Object::GetMTime` methods to return the maximum MTime between the two objects.

---

<div class="post-metadata">

### Author: ![Come](https://discourse.itk.org/letter_avatar_proxy/v4/letter/c/9f8e36/32.png) [@Come](https://discourse.itk.org/u/Come)
#### Post date: [July 7, 2020, 2:21pm UTC](https://discourse.itk.org/t/update-two-dependent-itk-dataobject/3269/4 "2020-07-07T14:21:22Z")

</div>

Thank you guys for the answers.  
@dzenanz correct me if I’m wrong but I think the `Modified` event is triggered by the `Update` method called on a `itk::ProcessObject` so every time my `itk::DataObjkect` is modified, the `Modified` event is triggered wright?

@blowekamp that would indeed give me the maximum `MTime` between the two objects but in this case, I need something that checks frequently the `MTime` value to make sure both objects are synchronized which means an Observer would be a better solution to avoid repeated check. I don’t see how I can use it to synchronize both objects?
