SIP4 python bindings for TQt
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

qsemaphore.sip 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // This is the SIP interface definition for TQSemaphore.
  2. //
  3. // Copyright (c) 2007
  4. // Riverbank Computing Limited <info@riverbankcomputing.co.uk>
  5. //
  6. // This file is part of PyTQt.
  7. //
  8. // This copy of PyTQt is free software; you can redistribute it and/or modify it
  9. // under the terms of the GNU General Public License as published by the Free
  10. // Software Foundation; either version 2, or (at your option) any later
  11. // version.
  12. //
  13. // PyTQt is supplied in the hope that it will be useful, but WITHOUT ANY
  14. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  15. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  16. // details.
  17. //
  18. // You should have received a copy of the GNU General Public License along with
  19. // PyTQt; see the file LICENSE. If not, write to the Free Software Foundation,
  20. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21. %ExportedDoc
  22. <Sect2><Title>TQSemaphore (TQt v2.2+)</Title>
  23. <Para>
  24. <Literal>TQSemaphore</Literal> is fully implemented. The <Literal>+=</Literal>
  25. and <Literal>-=</Literal> operators have also been implemented, but require
  26. Python v2.0 or later.
  27. </Para>
  28. </Sect2>
  29. %End
  30. %If (TQt_THREAD_SUPPORT)
  31. %If (TQt_3_0_0 -)
  32. class TQSemaphore
  33. {
  34. %TypeHeaderCode
  35. #include <qsemaphore.h>
  36. %End
  37. public:
  38. TQSemaphore(int);
  39. int available() const;
  40. int total() const;
  41. TQSemaphore &operator+=(int);
  42. %MethodCode
  43. // Some versions of TQt v3 under Windows have a bug where the +=
  44. // operator doesn't work properly (but ++ does). This way we
  45. // make sure that the most common value of n (ie. 1) works
  46. // properly with the buggy version.
  47. Py_BEGIN_ALLOW_THREADS
  48. if (a0 == 1)
  49. (*sipCpp)++;
  50. else
  51. (*sipCpp) += a0;
  52. Py_END_ALLOW_THREADS
  53. %End
  54. TQSemaphore &operator-=(int);
  55. %MethodCode
  56. // Some versions of TQt v3 under Windows have a bug where the -=
  57. // operator doesn't work properly (but -- does). This way we
  58. // make sure that the most common value of n (ie. 1) works
  59. // properly with the buggy version.
  60. Py_BEGIN_ALLOW_THREADS
  61. if (a0 == 1)
  62. (*sipCpp)--;
  63. else
  64. (*sipCpp) -= a0;
  65. Py_END_ALLOW_THREADS
  66. %End
  67. bool tryAccess(int);
  68. private:
  69. TQSemaphore(const TQSemaphore &);
  70. };
  71. %End
  72. %If (TQt_2_2_0 - TQt_3_0_0)
  73. class TQSemaphore : TQt
  74. {
  75. %TypeHeaderCode
  76. #include <qthread.h>
  77. %End
  78. public:
  79. TQSemaphore(int);
  80. int available() const;
  81. int total() const;
  82. TQSemaphore &operator+=(int);
  83. TQSemaphore &operator-=(int);
  84. private:
  85. TQSemaphore(const TQSemaphore &);
  86. };
  87. %End
  88. %End