Menu

Tree [r73] /
 History

HTTPS access


File Date Author Commit
 branches 2011-09-13 mdenwood [r73] update for epic meeting
 tags 2011-09-13 mdenwood [r73] update for epic meeting
 trunk 2011-09-13 mdenwood [r73] update for epic meeting
 Doxygen Quick Reference.pdf 2011-09-12 mdenwood [r67] update for epic meeting
 GSL library manual.pdf 2011-03-01 mdenwood [r35] added gsl manual and writefiles working
 README.txt 2011-09-12 mdenwood [r67] update for epic meeting
 inputs.csv 2011-09-12 mdenwood [r68] update before epic meeting
 reference manual (version 1).pdf 2011-09-12 mdenwood [r68] update before epic meeting
 unittest-cpp-1.4.zip 2010-12-01 mdenwood [r2] first c code

Read Me

For building documentation:  Doxygen
For unit testing: UnitTest++ (compiled and in epicmodel/ folder)
For stats: gsl (GNU scientific library)

Parameter file:
C++ demography class reads in input file - columns are : "Parameter Name","Agent Type","Agent Type ID","Parameter Type","Value"
Parameter name is what agent constructors match to, agent type is their type, agent type ID is the agent type number, parameter type is a check, value is the value.
Agent type ID can either be 0 in which case it matches to all agent type ID numbers, or it can be the specific number of agent type to which it applies
Each constructor sets up the parameters sequentially so (eg) actor first sets up its parmeters, then if this derives to another class it sets that up etc
So each class has more than 1 agent type ID corresponding to its number in that parent class




Requirements and basic usage etc

unittest++ on port (sudo port install unittest++) but also included
gsl required
R required for r interface

How to build R dynlib without xgrid


#######  Xcode instructions:

Partly from video:  http://www.youtube.com/watch?v=O0jQ4c3vfbw

Create new static library called model
In target info -> build, remove the entry in 'prefix header', add "/opt/local/include" to 'header search paths' and make 'inline methods hidden' and 'symbols hidden by default' both UNTICKED (make sure these are the same for all targets including the 2 below, for all configurations ie release and debug)
Add .h files to cope headers and .cpp files to compile sources and libgsl.a to link binary with libraries
(Add a run script:
cp ../R_interface/inputs.csv build/$CONFIGURATION/inputs.csv
to auto-copy the inputs file at link time so the whole directory can be excluded from Unison)
libmodel.a should now build

Create executable called UnitTest++, add model as direct dependency and link against, add testing files to compile sources
UnitTest++ should compile and run

Create executable called epicmodel (or main)
Add model as direct dependency and link against
Add UnitTest++ as direct dependency
Add main.cpp to compile sources (but not Rinterface.c)
Add run script: 
/Applications/Doxygen.app/Contents/Resources/doxygen Doxyfile
Add run script:
cd $TARGET_BUILD_DIR
./UnitTest++
Add run script BUT ensure /bin/bash not /bin/sh:
export PKG_CPPFLAGS='-I src -I src/base_classes -I src/fixed_classes -I /opt/local/include/'
if [ "$CONFIGURATION" == "Debug" ];
then
MAKEFLAGS="CXXFLAGS=-O0" R CMD SHLIB -c -o build/$CONFIGURATION/R_dynlib.so R_interface.cpp build/$CONFIGURATION/libmodel.a /opt/local/lib/libgsl.a
else
MAKEFLAGS="CXXFLAGS=-O3" R CMD SHLIB -c -o build/$CONFIGURATION/R_dynlib.so R_interface.cpp build/$CONFIGURATION/libmodel.a /opt/local/lib/libgsl.a
fi

Add run script:
cp build/$CONFIGURATION/R_dynlib.so ../R_interface/R_dynlib.so
cp build/$CONFIGURATION/epicmodel ../R_interface/epicmodel

epicmodel should now compile and run, and main.so is the R dynamic library


### Unittest++ etc:

Get unittest++ - easiest is:

sudo port install unittest-cpp

Which installs all the UnitTest++ header files (including the UnitTest++.h file) into /opt/local/include/unittest++ and the libUnitTest++.a library into /opt/local/lib/libUnitTest++.a
(but NOT any of the tests directory or other architectures)

Another option is to get the source from sourceforge and run sudo make at the root of the folder - this creates the libUnitTest++.a library there

Then to use create a test file for example:

//test.cpp
#include "/opt/local/include/unittest++/UnitTest++.h"

TEST(MyTest){
	CHECK(false);
}

int main(int, char const *[])
{
    return UnitTest::RunAllTests();
}
//End

And compile it AGAINST THE .a LIBRARY using:

g++ -o test test.cpp /opt/local/lib/libUnitTest++.a

And then run it using:

./test

Note that simply including /opt/local/include in the $PATH doesn't work, but there must be a way of adding /opt/local/include to the library search path for the compiler and using #include <unittest++/UnitTest++.h> instead

To get the same thing to work in Xcode, create a new target (shell command) called 'UnitTest++' and add the test.cpp file to that target.  Then add the absolute path to the .a file (eg UnitTest++/libUnitTest++.a if it is in the same folder) to the Build tab of the Target Info window, under 'other linker flags', and add '/opt/local/include' to the 'header search paths' of the same.  And make sure to switch the active target to run the tests.

To make the tests execute automatically, add the UnitTest++ target as a direct dependency to the main target (in the General Tab of the Target Info window), and then for the main target right click and Add:New Build Phase:New Run Script Build Phase and enter '$TARGET_BUILD_DIR/UnitTest++' in the script bit

UnitTest is currently set up using /opt/local/lib and /opt/local/include - it's a pain making sure all the search paths etc are correct and even then you have to specify the absolute path to /opt/local/lib/libUnitTest.a or whatever manually


http://acornheroes.com/2009/06/unit-testing-and-linking-static-libraries-with-xcode/
http://acornheroes.com/tag/xcode/

http://macdevcenter.com/pub/a/mac/2004/08/27/cocoa.html?page=3

For automagically doing code documentation:

Run Doxygen GUI once and make sure settings are good then save file as Doxyfile in root

Right-click on the PathDemo target and choose Add -> New Build Phase -> New Shell Script Build Phase.
3. Type the following into the Script text field:
/Applications/Doxygen.app/Contents/Resources/doxygen Doxyfile

http://developer.apple.com/tools/creatingdocsetswithdoxygen.html