Search code examples
redhawksdr

How to call a listener for structures and sequences of structures?


I have a property that is a structure in eclipse. How do I call the listener to know that a specific field was changed within the structure. Likewise, if I have a property that is a sequence of structures, how do I know which structure changed and which field within the structure changed.

I'm using C++ in Linux.

The structure property is named MyStruct. The member fields are MyField1 and MyField2. I'm using

setPropertyChangeListener("MyStruct", this, &MyComponent_i::myStrutChanged);

setPropertyChangeListener("MyStruct.MyField1", this, &MyComponent_i::myStructField1Changed);

setPropertyChangeListener("MyStruct.MyField2", this, &MyComponent_i::myStructField2Changed);

If a field is changed, setPropertyChangeListener("MyStruct", this, &MyComponent_i::myStrutChanged) is called. I need to know which field changed.

I also have a property that is a sequence of sturctures named MySeq. The structure has 2 member fields name SeqField1 and SeqField2. I'm using

setPropertyChangeListener("MySeq", this, &MyComponent_i::mySeqChanged);

setPropertyChangeListener("MySeq[1]", this, &MyComponent_i::mySeqChanged_1);

setPropertyChangeListener("MySeq[1].SeqField1", this, &MyComponent_i::mySeqChanged_1_field1);

setPropertyChangeListener("MySeq[1].SeqField2", this, &MyComponent_i::mySeqChanged_1_field2);

If a field in one of the structures is changed, setPropertyChangeListener(""MySeq", this, &MyComponent_i::mySeqChanged) is called. I need to know which structure was changed and which field within the structure was changed.


Solution

  • I would recommend that you create a private member variable of the struct type that you can compare with the incoming (changed) struct. You then can step through the fields to determine which field changed.