FFSM++  1.1.0
French Forest Sector Model ++
Sandbox.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2015 by Laboratoire d'Economie Forestière *
3  * http://ffsm-project.org *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 3 of the License, or *
8  * (at your option) any later version, given the compliance with the *
9  * exceptions listed in the file COPYING that is distribued together *
10  * with this file. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program; if not, write to the *
19  * Free Software Foundation, Inc., *
20  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  ***************************************************************************/
22 #ifndef SANDBOX_H
23 #define SANDBOX_H
24 
25 #include <QtCore>
26 #include <QThread>
27 #include <QString>
28 
29 #include "BaseClass.h"
30 
31 
32 /**
33 This is a test class used when I need to test some C++ or other library functions. It can safelly be removed by the project if needed.
34 
35  @author Antonello Lobianco <antonello@regmas.org>
36 */
37 
38 struct TestStructure;
39 
40 class Sandbox : public BaseClass {
41 
42 public:
43  Sandbox(ThreadManager* MTHREAD_h);
44  Sandbox();
45  ~Sandbox();
46 
47  template <class T> T getSetting(string name_h, int type);
48  template <class T> vector <T> getVectorSetting(string name_h, int type);
49  template <class T> T test2(const std::string& s); // e.g. int x = test<int>("123");
50  void printAString(string what){cout << "You printed: "<< what << endl;};
51  vector <TestStructure*> getTestStructure();
52  void testThreads();
53  void basicTest(); ///< Simple tests that doesn't require anything else (are encapsulated) and so they can be run at the beginning of the program. Normally empty
54  void fullTest(); ///< Tests that require a full sandbox object including MTHREAD. Normally empty
55  void testIpopt();
56  int testAdolc();
57  void testPartMatching(); ///< How to partial matching the key of a map
58  void testPartMatching2(); ///< How to partial matching the key of a map
59 
60 private:
61  vector <TestStructure> testVector;
62  // How to partial matching the key of a map
63 // map<string, string>::iterator FindPrefix(const map<string, string>& map, const string& search_for);
64  void testSearchMap(const map<string, string>& map, const string& search_for);
65  void testSearchMap2(const map<string, string>& map_h, const string& search_for);
66 };
67 
68 struct TestStructure {
69 
70  int i;
71  string s;
72  double cachedOffer;
73  double random;
74 };
75 
76 
77 class testThread : public QThread {
78  Q_OBJECT
79 
80 public:
81  testThread();
82  void assignJob(TestStructure* agent_h);
83 
84 protected:
85  void run();
86 
87 private:
88  volatile TestStructure* agent;
89 };
90 
91 
92 
93 #endif
void testPartMatching()
How to partial matching the key of a map.
Definition: Sandbox.cpp:1833
int testAdolc()
Definition: Sandbox.cpp:1758
void testPartMatching2()
How to partial matching the key of a map.
Definition: Sandbox.cpp:1870
void testIpopt()
Definition: Sandbox.cpp:1707
vector< TestStructure * > getTestStructure()
Definition: Sandbox.cpp:1572
volatile TestStructure * agent
Definition: Sandbox.h:88
void printAString(string what)
Definition: Sandbox.h:50
Thread manager. Responsable to manage the main thread and "speak" with the GUI.
Definition: ThreadManager.h:65
vector< T > getVectorSetting(string name_h, int type)
string s
Definition: Sandbox.h:71
vector< TestStructure > testVector
Definition: Sandbox.h:61
void testSearchMap2(const map< string, string > &map_h, const string &search_for)
Definition: Sandbox.cpp:1856
Sandbox()
Definition: Sandbox.cpp:85
void fullTest()
Tests that require a full sandbox object including MTHREAD. Normally empty.
Definition: Sandbox.cpp:599
~Sandbox()
Definition: Sandbox.cpp:90
double random
Definition: Sandbox.h:73
Base class for the regmas application.
Definition: BaseClass.h:239
T test2(const std::string &s)
Definition: Sandbox.cpp:1563
T getSetting(string name_h, int type)
Definition: Sandbox.cpp:1518
double cachedOffer
Definition: Sandbox.h:72
This file is the header of BaseClass and it is included by ALL compiled code.
void testSearchMap(const map< string, string > &map, const string &search_for)
Definition: Sandbox.cpp:1818
void testThreads()
Definition: Sandbox.cpp:1585
void basicTest()
Simple tests that doesn&#39;t require anything else (are encapsulated) and so they can be run at the begi...
Definition: Sandbox.cpp:132