1 /*
2  *  cDemeNetwork.cpp
3  *  Avida
4  *
5  *  Copyright 1999-2011 Michigan State University. All rights reserved.
6  *
7  *
8  *  This file is part of Avida.
9  *
10  *  Avida is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
11  *  as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
12  *
13  *  Avida is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
15  *
16  *  You should have received a copy of the GNU Lesser General Public License along with Avida.
17  *  If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #include "avida/Avida.h"
22 
23 #include "avida/core/WorldDriver.h"
24 
25 #include "cDeme.h"
26 #include "cDemeNetwork.h"
27 #include "cWorld.h"
28 
29 /* By default, Boost is not available.  To enable Boost, either modify your environment,
30  alter your build settings, or change this value -- BUT BE CAREFUL NOT TO CHECK IT IN LIKE THAT!
31  */
32 #ifndef BOOST_IS_AVAILABLE
33 #define BOOST_IS_AVAILABLE 0
34 #endif
35 
36 // Conditional includes (these use the BGL).
37 #if BOOST_IS_AVAILABLE
38 #include "cDemeTopologyNetwork.h"
39 #endif
40 
41 using namespace Avida;
42 
43 
44 /*! Creates a cDemeNetwork object.
45 
46  WARNING: This method throws an exception if BOOST_IS_AVAILABLE is not 1, as this
47  indicates at *least* a configuration error.
48 
49  WARNING: The returned pointer is owned by the caller (you're responsible for deleting it)!
50  */
DemeNetworkFactory(cWorld * world,cDeme & deme)51 cDemeNetwork* cDemeNetwork::DemeNetworkFactory(cWorld* world, cDeme& deme) {
52 #if BOOST_IS_AVAILABLE
53 	switch(world->GetConfig().DEME_NETWORK_TYPE.Get()) {
54 		case cDemeNetwork::TOPOLOGY: {
55 			return new cDemeTopologyNetwork(world, deme);
56 		}
57 		default: {
58 			world->GetDriver().RaiseFatalException(-1, "Unrecognized network type in cDemeNetwork::DemeNetworkFactory().");
59 		}
60 	}
61 #else
62 	world->GetDriver().RaiseFatalException(-1, "cDemeNetwork requires Boost; if Boost *is* available, #define BOOST_IS_AVAILABLE in defs.h, and (possibly) update your include path.");
63 #endif
64 	return 0; // never reached, to quell warnings only.
65 }
66 
67 /*! Constructor.
68  */
cDemeNetwork(cWorld * world,cDeme & deme)69 cDemeNetwork::cDemeNetwork(cWorld* world, cDeme& deme) : m_world(world), m_deme(deme) {
70 }
71