MirrorPath.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #include "MirrorPath.h"
  2. #include "FileService.h"
  3. MirrorPath::MirrorPath(const char * _from, const char * _on, const char * _realPathFrom, const char * _realPathOn, const char * _cppFileName, long _cppFileLine)
  4. {
  5. node = null;
  6. from = _from;
  7. on = _on;
  8. pathFrom = _realPathFrom;
  9. pathOn = _realPathOn;
  10. refCount = 1;
  11. #ifndef STOP_DEBUG
  12. cppFileName = _cppFileName;
  13. cppFileLine = _cppFileLine;
  14. #endif
  15. }
  16. MirrorPath::~MirrorPath()
  17. {
  18. }
  19. //Удалить объект, сообщив об ошибке
  20. void MirrorPath::ErrorRelease()
  21. {
  22. #ifndef STOP_DEBUG
  23. api->Trace("FileService error: IMirrorPath not released (file: %s, line: %i)", cppFileName, cppFileLine);
  24. #endif
  25. delete this;
  26. }
  27. //Этот ли объект
  28. bool MirrorPath::IsThis(const string & _from, const string & _on)
  29. {
  30. if(pathFrom == _from)
  31. {
  32. if(pathOn == _on)
  33. {
  34. return true;
  35. }
  36. }
  37. return false;
  38. }
  39. //Увеличить счётчик объектов
  40. void MirrorPath::AddRefCount()
  41. {
  42. refCount++;
  43. }
  44. //Удалить объект, закончив отражать путь
  45. void MirrorPath::Release()
  46. {
  47. {
  48. SingleExClassThread(FileService::object)
  49. refCount--;
  50. if(refCount > 0)
  51. {
  52. return;
  53. }
  54. FileService::object->DeleteMirrorPath(this);
  55. }
  56. delete this;
  57. }
  58. //Получить путь который отражается
  59. const char * MirrorPath::From()
  60. {
  61. return from;
  62. }
  63. //Получить путь на который отражается
  64. const char * MirrorPath::On()
  65. {
  66. return on;
  67. }
  68. //Установить нод к которому привязан объект
  69. void MirrorPath::SetNode(void * _node)
  70. {
  71. node = _node;
  72. }
  73. //Получить нод к которому привязан объект
  74. void * MirrorPath::GetNode()
  75. {
  76. return node;
  77. }