Mantid
Loading...
Searching...
No Matches
Framework
PythonInterface
core
inc
MantidPythonInterface
core
Converters
MapToPyDictionary.h
Go to the documentation of this file.
1
// Mantid Repository : https://github.com/mantidproject/mantid
2
//
3
// Copyright © 2015 ISIS Rutherford Appleton Laboratory UKRI,
4
// NScD Oak Ridge National Laboratory, European Spallation Source,
5
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6
// SPDX - License - Identifier: GPL - 3.0 +
7
#pragma once
8
12
#include "
MantidKernel/System.h
"
13
#include <boost/python/dict.hpp>
14
#include <boost/python/object.hpp>
15
#include <map>
16
17
namespace
Mantid
{
18
namespace
PythonInterface {
19
namespace
Converters
{
20
21
template
<
typename
KeyType,
typename
ValueType>
struct
DLLExport
MapToPyDictionary
{
22
23
public
:
24
using
MapType
= std::map<KeyType, ValueType>;
25
26
MapToPyDictionary
(
const
MapType
&map) : m_map(map) {}
28
boost::python::dict
operator()
() {
29
using namespace
boost::python
;
30
boost::python::dict dictionary;
31
for
(
const
auto
&pair : this->m_map) {
32
dictionary[object(pair.first)] = object(pair.second);
33
}
34
return
dictionary;
35
}
36
37
private
:
39
MapType
m_map
;
40
};
41
}
// namespace Converters
42
}
// namespace PythonInterface
43
}
// namespace Mantid
System.h
DLLExport
#define DLLExport
Definitions of the DLLImport compiler directives for MSVC.
Definition
System.h:37
Mantid::PythonInterface::Converters
Definition
CArrayToNDArray.h:13
Mantid
Helper class which provides the Collimation Length for SANS instruments.
Definition
AbsorptionCorrection.h:18
boost::python
Definition
NDArray.h:50
Mantid::PythonInterface::Converters::MapToPyDictionary
Definition
MapToPyDictionary.h:21
Mantid::PythonInterface::Converters::MapToPyDictionary::MapToPyDictionary
MapToPyDictionary(const MapType &map)
Definition
MapToPyDictionary.h:26
Mantid::PythonInterface::Converters::MapToPyDictionary::operator()
boost::python::dict operator()()
Produces a python dictionary.
Definition
MapToPyDictionary.h:28
Mantid::PythonInterface::Converters::MapToPyDictionary::m_map
MapType m_map
Map.
Definition
MapToPyDictionary.h:39
Mantid::PythonInterface::Converters::MapToPyDictionary::MapType
std::map< KeyType, ValueType > MapType
Definition
MapToPyDictionary.h:24
Generated by
1.9.8