bioweb  0.09.92
C++/Python(django)/JavaScript(angularJS) framework
calcpy.cpp
Go to the documentation of this file.
1 
6 #if defined(_MSC_VER) && (_MSC_VER >= 1400)
7 //msvc disable warnings for Boost.Python
8 #pragma warning(disable:4100)
9 #pragma warning(disable:4127)
10 #pragma warning(disable:4244)
11 #pragma warning(disable:4267)
12 #pragma warning(disable:4512)
13 #endif
14 
15 
16 #include <boost/python.hpp>
17 #include <boost/python/suite/indexing/vector_indexing_suite.hpp>
18 
19 #include "calc.hpp"
20 
21 using namespace boost::python;
22 
26 public:
27  std::vector<long> getIds() {
28  return CommandManager::getInstance().commandKeys();
29  }
30 
31  long startTick() {
32  return CommandManager::getInstance().runTickCommand(200); //4 sec here! (in C++ tests 0.2 s. command is used)
33  }
34  void breakCmd(long) {
35  //TODO
36  }
37  mt4cpp::CommandDesc::State getState(long id) { return CommandManager::getInstance().findCommandDesc(id).state_; }
38  double getProgress(long id) { return CommandManager::getInstance().findCommandDesc(id).progress_; }
39 };
40 
45 {
47  boost::python::def( "getNumber", getNumber );
48 
49  boost::python::enum_<mt4cpp::CommandDesc::State>("CommandState")
50  .value("NONE",mt4cpp::CommandDesc::NONE)
51  .value("QUEUED",mt4cpp::CommandDesc::QUEUED)
52  .value("PENDING",mt4cpp::CommandDesc::PENDING)
53  .value("INTERRUPTED",mt4cpp::CommandDesc::INTERRUPTED)
54  .value("EXCEPTION",mt4cpp::CommandDesc::EXCEPTION)
55  .value("DONE",mt4cpp::CommandDesc::DONE)
56  .export_values()
57  ;
58 
59  class_<std::vector<long> >("CommandKeys")
60  .def(vector_indexing_suite<std::vector<long> >() )
61  ;
62 
63  class_<CommandManagerPy>("CommandManager")
64  .def( "getIds", &CommandManagerPy::getIds )
65  .def( "start", &CommandManagerPy::startTick )
66  .def( "break", &CommandManagerPy::breakCmd )
67  .def( "getState", &CommandManagerPy::getState )
68  .def( "getProgress", &CommandManagerPy::getProgress )
69  ;
70 
71 }
the C++ calculation library interface
BOOST_PYTHON_MODULE(calc)
Definition: calcpy.cpp:44