[Clam-devel] TypedControls Patch

Pau Arumí parumi at iua.upf.edu
Fri May 9 11:07:59 PDT 2008


On dj, 2008-05-08 at 14:43 -0300, Francisco Tufró wrote:
> After some hours of work i have done 2 tests and passed them.
> Just check them and tell me if they're ok (and if the patch is well
> done ^^)
> :)

Good start! I see the code checked in by Hernan.
It's is good to go in small steps. Even this simple test brings out some
issues:


+               {
+                       CLAM::TypedInControl<int> in("IntInControl");
+                       CLAM::TypedOutControl<int> out("IntOutControl");
+                       out.AddLink(in);
+                       int number=1;
+                       out.SendControl(number);
+                       CPPUNIT_ASSERT_EQUAL( 1 , in.GetLastValue() );
+               }
+

out.SendControl(1); won't work because the signature wants a reference
to a non-constant var! And we need it to work, for backwards
compatibility among other reasons.

So change the test passing a constant, and pass the test by changing
SendControl and DoControl arguments to be const references.

We want controls to be passed by copy (or maybe in the future:
copy-on-write smart pointers), but keeping a reference to the original
object is bad. 

I was considering a new "sent by copy" test (e.g. send a var, change the
var, check that the received value has not changed) but i realize it is
not necessary, once we have changed the previous test: if you save a a
const argument it necessarily implies doing copy.

> When you give me the ok, i'll continue with the
> "TypedInControl::IsConnected(out)" test.
> Bye!

Yes

Pau





More information about the clam-devel mailing list