feat: Added Mds class

This commit is contained in:
AURUMVORXX
2024-11-09 04:03:33 +03:00
parent 58ec459ea5
commit 0b89806626
9 changed files with 109 additions and 15 deletions

View File

@@ -6,6 +6,7 @@
#include "classes/py/Daedalus.h"
#include "classes/py/Sky.h"
#include "classes/py/ItemsGround.h"
#include "classes/py/Mds.h"
#include "functions/pyfunctions.h"
@@ -100,6 +101,13 @@ PYBIND11_EMBEDDED_MODULE(sqg2o, m) {
.def_static("create", [](py::dict value){ return PyItemsGround::create(value); })
.def_static("destroy", [](int value){ return PyItemsGround::destroy(value); });
// -------------------------------------------------------------------------
py::class_<PyMds>(m, "Mds")
.def_static("id", [](std::string value){ return PyMds::id(value); })
.def_static("name", [](int value){ return PyMds::name(value); });
// -------------------------------------------------------------------------
m.def("getHostname", &py_getHostname);

17
src/classes/py/Mds.h Normal file
View File

@@ -0,0 +1,17 @@
#ifndef _PYMDS_H
#define _PYMDS_H
#include <classes/sq/Mds.h>
#include <pybind11/embed.h>
namespace py = pybind11;
class PyMds
{
public:
static int id(std::string mdsName) { return nonut::Mds::get()->id(mdsName); }
static std::string name(int mdsId) { return nonut::Mds::get()->name(mdsId); }
};
#endif

22
src/classes/sq/Mds.cpp Normal file
View File

@@ -0,0 +1,22 @@
#include <NoNut/core/CommonHeader.h>
#include "Mds.h"
namespace nonut
{
Mds* Mds::get()
{
if (inst == nullptr)
{
inst = new Mds();
}
return inst;
}
Mds::Mds() :
StaticClass("Mds"),
METHOD_CTOR(id),
METHOD_CTOR(name)
{
}
}

26
src/classes/sq/Mds.h Normal file
View File

@@ -0,0 +1,26 @@
#ifndef _MDS_H
#define _MDS_H
#include <string>
#include <NoNut/core/StaticClass.h>
#include <NoNut/core/CustomTypes.h>
namespace nonut
{
class Mds : public StaticClass
{
public:
static Mds* get();
Function<Int, String> id;
Function<String, Int> name;
private:
static inline Mds* inst = nullptr;
Mds();
};
}
#endif