feat: Added PyG2O python library

This commit is contained in:
AURUMVORXX
2024-11-02 11:28:09 +03:00
parent 8fa4b6a6f9
commit a6e8dfa684
3 changed files with 49 additions and 0 deletions

View File

@@ -114,4 +114,12 @@ add_custom_command(
POST_BUILD
COMMAND ${CMAKE_COMMAND}
-E copy_directory ${CPYTHON_STDLIB_DIR} $<TARGET_FILE_DIR:${PROJECT_NAME}>/lib
)
# Copy the PyG2O library into the build/lib folder
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND}
-E copy_directory ${CMAKE_SOURCE_DIR}/g2o $<TARGET_FILE_DIR:${PROJECT_NAME}>/lib/g2o
)

5
g2o/__init__.py Normal file
View File

@@ -0,0 +1,5 @@
from g2o.events import addEvent
from g2o.events import callEvent
from g2o.events import event
from g2o.events import removeEventHandler

36
g2o/events.py Normal file
View File

@@ -0,0 +1,36 @@
eventList = {}
def callEvent(name, **args):
if name in eventList:
for event in eventList[name]:
event['function'](**args)
def addEvent(name):
if not name in eventList:
eventList[name] = []
def event(name, priority = 9999):
def inlineEvt(func):
if not name in eventList:
pass
eventList[name].append({'function': func, 'priority': priority})
eventList[name].sort(key = lambda x: x['priority'])
return func
return inlineEvt
def removeEventHandler(name, func):
if not name in eventList:
pass
for index, item in enumerate(eventList[name]):
if item['function'] == func:
del eventList[name][index]
## registering all the events
addEvent('onInit')
addEvent('onExit')
addEvent('onTick')
addEvent('onTime')