/[escript]/branches/arrexp_2137_win/escript/test/SharedDataTestCase.h
ViewVC logotype

Contents of /branches/arrexp_2137_win/escript/test/SharedDataTestCase.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2212 - (show annotations)
Wed Jan 14 00:15:00 2009 UTC (11 years, 5 months ago) by jfenwick
File MIME type: text/plain
File size: 1328 byte(s)
Executive summary:

This commit adds copy on write checks to operations involving shared data. 

Changes:

new #defines:
~~~~~~~~~~~~~
Data.cpp has ASSIGNMENT_MEANS_DEEPCOPY (defaults to undefined).
Defining this will put the data = operator back to making deep copies instead
of sharing data (now the default.)

Data:
~~~~~
. Added exclusiveWrite method to copy the underlying data if it is shared.
. Some operators which took python objects now call the c++ versions intead of duplicating code.

DataAbstract and offspring:
~~~~~~~~~~~~~~~~~~~~~~~~~~~
. Added method to determine whether the data is currently shared.
. Added getVectorRO to children of DataReady.
. Added getTagRO.

. Operations which modify values in place (or return modifiable pointers) now use
a macro to check for sharing. In the case where a modification attempt is detected, it throws an exception. In the future, I will enable this only for debugging.

. This shold not really have been required but the compiler was not choosing the use the const version as I would have liked. Besides, this makes things explict.

. Moved (and de-inlined) getVector in DataConstant (It was virtual in a parent class).

Unit tests:
~~~~~~~~~~~
Added both python and c++ unit tests to check known cases of sharing and "inplace"
modification operations.

General:
~~~~~~~~
Removed some commented out code.

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2008 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 *******************************************************/
13
14
15 #if !defined SHAREDDATATESTCASE_H
16 #define SHAREDDATATESTCASE_H
17
18 #include "tools/CppUnitTest/TestCase.h"
19 #include "tools/CppUnitTest/TestSuite.h"
20 #include "tools/CppUnitTest/TestCaller.h"
21
22 class SharedDataTestCase : public CppUnitTest::TestCase
23 {
24 public:
25
26 //
27 // setUp is called before each test method to set up test state
28 void setUp();
29 //
30 // tearDown is called after each test method is called.
31 void tearDown();
32
33 //
34 // A test method must return void and have no arguments
35 void testEQ();
36 void testCC();
37 void testAssign();
38 void testSetToZero();
39 void setTaggedValueFromCPP();
40 void testSetTaggedValueFromCPP();
41 void testGetDataAtOffset();
42 void testGetDataPoint();
43 void testGetSampleRW();
44
45
46 SharedDataTestCase (std::string name) : TestCase (name) {}
47 ~SharedDataTestCase() {}
48 //
49 //
50 // return the suite of tests to perform
51 //
52 static CppUnitTest::TestSuite* suite ();
53 };
54
55 #endif

  ViewVC Help
Powered by ViewVC 1.1.26