DrvTree.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #pragma once
  2. #include <map>
  3. #include <vector>
  4. #include <string>
  5. #include "CcosLock.h"
  6. #include "CcosThread.h"
  7. #include "LogicClient.h"
  8. using namespace std;
  9. class DrvTreeNode {
  10. //bool Check_AddSubNode(DrvTreeNode &SubNode);
  11. public:
  12. DrvTreeNode(void);
  13. virtual ~DrvTreeNode(void);
  14. //data definitions
  15. //bool m_EndNode;
  16. UINT64 m_ProcId;
  17. UINT64 m_Address;
  18. //string *m_NodeName;
  19. //map<string,DrvTreeNode> *m_SubNodes;
  20. //functions
  21. //void InitTreeNode(const char *pNodeName, UINT64 ProcId = 0, UINT64 Address = 0);
  22. //bool AddSubNode(DrvTreeNode &SubNode);
  23. //bool DelSubPath(const char *pSubPath);
  24. //const char* GetNodeName();
  25. };
  26. //-------------README-----------
  27. /*
  28. 驱动树作为设备的管理员存在.
  29. 所有针对设备的操作,必须先Lock驱动树,然后进行操作
  30. 1.插入/删除/检索设备的操作
  31. 2.插入/删除/检索设备句柄的操作
  32. 3.插入/删除/检索驱动句柄的操作
  33. */
  34. class DrvTree : public CcosLock, public Thread_Base
  35. {
  36. LogicClient * m_rootClient;
  37. map<string, DrvTreeNode> *m_DrvTreeMap;
  38. map<UINT64,vector<UINT64>> *m_LocalProcIdList;//key = procid,vector = address
  39. public:
  40. DrvTree();
  41. virtual ~DrvTree();
  42. void Clear();
  43. bool AddTree(const char *pDevicePath, UINT64 ProcId, UINT64 Address);
  44. bool DelTree(const char *pDevicePath);
  45. bool GetTreeNode(const char *pDevicePath, DrvTreeNode &node);
  46. bool CheckNode(UINT64 ProcId, UINT64 Address);
  47. void PrintExistTree();
  48. protected:
  49. //thread
  50. virtual bool Exec();
  51. virtual bool OnStartThread();
  52. virtual bool OnEndThread();
  53. };
  54. extern DrvTree g_DrvTree;