update command

This commit is contained in:
matheuter 2023-04-20 17:19:00 +08:00
parent 527db1baa7
commit 4ab86338f1
12 changed files with 93 additions and 103 deletions

View File

@ -1,4 +1,4 @@
#pragma once

#include <cstdint>
#include <string>
#include <memory>
@ -7,10 +7,6 @@
#include "functiontraits.h"
/**
* @brief Actor class, which encapsulates the event model
* @note enable_shared_from_this allows us to get safe Pointers internally
*/
class Actor : public std::enable_shared_from_this<Actor>
{
public:
@ -21,27 +17,18 @@ public:
Actor(){}
~Actor(){}
/**
* @brief Register the callback function and construct the anonymous function with std::bind
*/
template<typename Function>
void operator+=(Function&& function_any) noexcept
{
m_invokeFunctionWapper = { std::bind(&invoker<Function>::apply, function_any, std::placeholders::_1, std::placeholders::_2) };
}
/**
* @brief Register the callback function and construct the anonymous function with std::bind
*/
template<typename Function>
void registerFunction(Function&& function_any) noexcept
{
m_invokeFunctionWapper = { std::bind(&invoker<Function>::apply, function_any, std::placeholders::_1, std::placeholders::_2) };
}
/**
* @brief Register the callback function and construct the anonymous function with std::bind
*/
template<typename ... Args>
void invoke(Args&& ... args) const noexcept
{
@ -49,9 +36,6 @@ public:
m_invokeFunctionWapper(&args_tuple, nullptr);
}
/**
* @brief Register the callback function and construct the anonymous function with std::bind
*/
template<typename R, typename ... Args>
R invoke(Args&& ...args) const
{
@ -66,12 +50,8 @@ public:
return return_value;
}
Ptr getSharedPtr()
{
return shared_from_this();
}
public:
/**
* @brief This struct encapsulates a function,
* essentially storing the return value and parameters in two variables

View File

@ -1,11 +1,9 @@
#include "actorprocessor.h"
#include "actorprocessor.h"
ActorProcessor::ActorProcessor():
m_actorMap(new std::unordered_map<std::string, Actor*>)
{}
/**
* @brief
*/
ActorProcessor::~ActorProcessor()
{
for (auto& item : (*m_actorMap))
@ -17,17 +15,11 @@ ActorProcessor::~ActorProcessor()
delete m_actorMap;
}
/**
* @brief
*/
void ActorProcessor::registerActor(const std::string &route, Actor *actor)
{
m_actorMap->insert(std::make_pair(route,actor));
}
/**
* @brief
*/
void ActorProcessor::removeActor(const std::string &route)
{
auto iter = (*m_actorMap).find(route);
@ -38,9 +30,6 @@ void ActorProcessor::removeActor(const std::string &route)
}
}
/**
* @brief
*/
Actor *ActorProcessor::findActor(const std::string &route)
{
auto iter = (*m_actorMap).find(route);
@ -51,9 +40,7 @@ Actor *ActorProcessor::findActor(const std::string &route)
return nullptr;
}
/**
* @brief
*/
bool ActorProcessor::resetActor(const std::string &route, Actor *actor)
{
auto iter = (*m_actorMap).find(route);

View File

@ -1,5 +1,5 @@
#ifndef EVENTPROCESSOR_H
#define EVENTPROCESSOR_H
#ifndef _PROCESSOR_H
#define _PROCESSOR_H
#include <string>
#include <functional>
@ -25,9 +25,6 @@ public:
(*m_actorMap)[route]->invoke(std::forward<Args>(args)...);
}
/**
* @brief Register the callback function and construct the anonymous function with std::bind
*/
template<typename R, typename ... Args>
R invoke(const std::string& route,Args&& ...args) const
{
@ -36,30 +33,16 @@ public:
return nullptr;
}
/**
* @brief actorroute是唯一的
*/
void registerActor(const std::string& route, Actor*actor);
/**
* @brief actor
*/
void removeActor(const std::string& route);
/**
* @brief actor
*/
Actor* findActor(const std::string& route);
/**
* @brief actoractor会被删除
*/
bool resetActor(const std::string& route,Actor*actor);
private:
std::unordered_map<std::string, Actor*>* m_actorMap;
private:
// not allow copy constroct
ActorProcessor(ActorProcessor&&)=delete;
ActorProcessor& operator=(const ActorProcessor&)=delete;
};

View File

@ -1,6 +0,0 @@
#include "abstractfile.h"
AbstractFile::AbstractFile()
{
}

View File

@ -1,11 +0,0 @@
#ifndef ABSTRACTFILE_H
#define ABSTRACTFILE_H
class AbstractFile
{
public:
AbstractFile();
};
#endif // ABSTRACTFILE_H

View File

@ -1,6 +1,6 @@
/**
** This file is part of ndd file tree view plugin
** Copyright 2022-2023 ji wang <matheuter@gmail.com>.
** This file is part of ndd plugin file tree view
** Copyright ji wang <matheuter@gmail.com>.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as
@ -16,6 +16,7 @@
** along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
#pragma once
#include <cstdint>
#include <string>

View File

@ -1,3 +1,22 @@
/**
** This file is part of ndd plugin file tree view
** Copyright ji wang <matheuter@gmail.com>.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as
** published by the Free Software Foundation, either version 3 of the
** License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
#include "actorprocessor.h"
ActorProcessor::ActorProcessor():
m_actorMap(new std::unordered_map<std::string, Actor*>)

View File

@ -1,5 +1,24 @@
#ifndef EVENTPROCESSOR_H
#define EVENTPROCESSOR_H
/**
** This file is part of ndd plugin file tree view
** Copyright ji wang <matheuter@gmail.com>.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as
** published by the Free Software Foundation, either version 3 of the
** License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef _PROCESSOR_H
#define _PROCESSOR_H
#include <string>
#include <functional>
@ -15,9 +34,6 @@ public:
~ActorProcessor();
public:
/**
* @brief Register the callback function and construct the anonymous function with std::bind
*/
template<typename ... Args>
void invoke(const std::string& route,Args&& ... args) const noexcept
{
@ -25,9 +41,6 @@ public:
(*m_actorMap)[route]->invoke(std::forward<Args>(args)...);
}
/**
* @brief Register the callback function and construct the anonymous function with std::bind
*/
template<typename R, typename ... Args>
R invoke(const std::string& route,Args&& ...args) const
{
@ -36,24 +49,12 @@ public:
return nullptr;
}
/**
* @brief actorroute是唯一的
*/
void registerActor(const std::string& route, Actor*actor);
/**
* @brief actor
*/
void removeActor(const std::string& route);
/**
* @brief actor
*/
Actor* findActor(const std::string& route);
/**
* @brief actoractor会被删除
*/
bool resetActor(const std::string& route,Actor*actor);
private:

View File

@ -1,6 +1,6 @@
/**
** This file is part of the NoteBook project.
** Copyright 2022 ji wang <matheuter@gmail.com>.
** This file is part of ndd plugin file tree view
** Copyright ji wang <matheuter@gmail.com>.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as

View File

@ -1,6 +1,6 @@
/**
** This file is part of the NoteBook project.
** Copyright 2022 ji wang <matheuter@gmail.com>.
** This file is part of ndd plugin file tree view
** Copyright ji wang <matheuter@gmail.com>.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as
@ -16,7 +16,6 @@
** along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef WORKSPACE_H
#define WORKSPACE_H

View File

@ -8,6 +8,24 @@
#include <QDir>
#include <QTreeView>
#include <QDebug>
/**
** This file is part of ndd plugin file tree view
** Copyright ji wang <matheuter@gmail.com>.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as
** published by the Free Software Foundation, either version 3 of the
** License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
#include <qsciscintilla.h>

View File

@ -1,4 +1,23 @@
#ifndef FILETREEWIDGET_H
/**
** This file is part of ndd plugin file tree view
** Copyright ji wang <matheuter@gmail.com>.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as
** published by the Free Software Foundation, either version 3 of the
** License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef FILETREEWIDGET_H
#define FILETREEWIDGET_H
#include <QWidget>