nsIRDFDataSource.idl 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "nsISupports.idl"
  6. #include "nsIRDFResource.idl"
  7. #include "nsIRDFNode.idl"
  8. #include "nsISimpleEnumerator.idl"
  9. #include "nsIRDFObserver.idl"
  10. [scriptable, uuid(0F78DA58-8321-11d2-8EAC-00805F29F370)]
  11. interface nsIRDFDataSource : nsISupports
  12. {
  13. /** The "URI" of the data source. This used by the RDF service's
  14. * |GetDataSource()| method to cache datasources.
  15. */
  16. readonly attribute string URI;
  17. /** Find an RDF resource that points to a given node over the
  18. * specified arc & truth value
  19. *
  20. * @throws NS_RDF_NO_VALUE if there is no source that leads
  21. * to the target with the specified property.
  22. */
  23. nsIRDFResource GetSource(in nsIRDFResource aProperty,
  24. in nsIRDFNode aTarget,
  25. in boolean aTruthValue);
  26. /**
  27. * Find all RDF resources that point to a given node over the
  28. * specified arc & truth value
  29. */
  30. nsISimpleEnumerator GetSources(in nsIRDFResource aProperty,
  31. in nsIRDFNode aTarget,
  32. in boolean aTruthValue);
  33. /**
  34. * Find a child of that is related to the source by the given arc
  35. * arc and truth value
  36. *
  37. * @throws NS_RDF_NO_VALUE if there is no target accessible from the
  38. * source via the specified property.
  39. */
  40. nsIRDFNode GetTarget(in nsIRDFResource aSource,
  41. in nsIRDFResource aProperty,
  42. in boolean aTruthValue);
  43. /**
  44. * Find all children of that are related to the source by the given arc
  45. * arc and truth value.
  46. */
  47. nsISimpleEnumerator GetTargets(in nsIRDFResource aSource,
  48. in nsIRDFResource aProperty,
  49. in boolean aTruthValue);
  50. /**
  51. * Add an assertion to the graph.
  52. */
  53. void Assert(in nsIRDFResource aSource,
  54. in nsIRDFResource aProperty,
  55. in nsIRDFNode aTarget,
  56. in boolean aTruthValue);
  57. /**
  58. * Remove an assertion from the graph.
  59. */
  60. void Unassert(in nsIRDFResource aSource,
  61. in nsIRDFResource aProperty,
  62. in nsIRDFNode aTarget);
  63. /**
  64. * Change an assertion from
  65. *
  66. * [aSource]--[aProperty]-->[aOldTarget]
  67. *
  68. * to
  69. *
  70. * [aSource]--[aProperty]-->[aNewTarget]
  71. */
  72. void Change(in nsIRDFResource aSource,
  73. in nsIRDFResource aProperty,
  74. in nsIRDFNode aOldTarget,
  75. in nsIRDFNode aNewTarget);
  76. /**
  77. * 'Move' an assertion from
  78. *
  79. * [aOldSource]--[aProperty]-->[aTarget]
  80. *
  81. * to
  82. *
  83. * [aNewSource]--[aProperty]-->[aTarget]
  84. */
  85. void Move(in nsIRDFResource aOldSource,
  86. in nsIRDFResource aNewSource,
  87. in nsIRDFResource aProperty,
  88. in nsIRDFNode aTarget);
  89. /**
  90. * Query whether an assertion exists in this graph.
  91. */
  92. boolean HasAssertion(in nsIRDFResource aSource,
  93. in nsIRDFResource aProperty,
  94. in nsIRDFNode aTarget,
  95. in boolean aTruthValue);
  96. /**
  97. * Add an observer to this data source. If the datasource
  98. * supports observers, the datasource source should hold a strong
  99. * reference to the observer.
  100. */
  101. void AddObserver(in nsIRDFObserver aObserver);
  102. /**
  103. * Remove an observer from this data source.
  104. */
  105. void RemoveObserver(in nsIRDFObserver aObserver);
  106. /**
  107. * Get a cursor to iterate over all the arcs that point into a node.
  108. */
  109. nsISimpleEnumerator ArcLabelsIn(in nsIRDFNode aNode);
  110. /**
  111. * Get a cursor to iterate over all the arcs that originate in
  112. * a resource.
  113. */
  114. nsISimpleEnumerator ArcLabelsOut(in nsIRDFResource aSource);
  115. /**
  116. * Retrieve all of the resources that the data source currently
  117. * refers to.
  118. */
  119. nsISimpleEnumerator GetAllResources();
  120. /**
  121. * Returns whether a given command is enabled for a set of sources.
  122. */
  123. boolean IsCommandEnabled(in nsISupports aSources,
  124. in nsIRDFResource aCommand,
  125. in nsISupports aArguments);
  126. /**
  127. * Perform the specified command on set of sources.
  128. */
  129. void DoCommand(in nsISupports aSources,
  130. in nsIRDFResource aCommand,
  131. in nsISupports aArguments);
  132. /**
  133. * Returns the set of all commands defined for a given source.
  134. */
  135. nsISimpleEnumerator GetAllCmds(in nsIRDFResource aSource);
  136. /**
  137. * Returns true if the specified node is pointed to by the specified arc.
  138. * Equivalent to enumerating ArcLabelsIn and comparing for the specified arc.
  139. */
  140. boolean hasArcIn(in nsIRDFNode aNode, in nsIRDFResource aArc);
  141. /**
  142. * Returns true if the specified node has the specified outward arc.
  143. * Equivalent to enumerating ArcLabelsOut and comparing for the specified arc.
  144. */
  145. boolean hasArcOut(in nsIRDFResource aSource, in nsIRDFResource aArc);
  146. /**
  147. * Notify observers that the datasource is about to send several
  148. * notifications at once.
  149. * This must be followed by calling endUpdateBatch(), otherwise
  150. * viewers will get out of sync.
  151. */
  152. void beginUpdateBatch();
  153. /**
  154. * Notify observers that the datasource has completed issuing
  155. * a notification group.
  156. */
  157. void endUpdateBatch();
  158. };