SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
ArcImplementation.h
1 //=========================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //=========================================================================
10 
11 #ifndef smtk_graph_ArcImplementation_h
12 #define smtk_graph_ArcImplementation_h
13 
14 #include "smtk/common/Visit.h"
15 #include "smtk/graph/detail/TypeTraits.h"
16 #include "smtk/resource/Component.h"
17 #include "smtk/string/Token.h"
18 
19 namespace smtk
20 {
21 namespace graph
22 {
23 
25 template<bool Constness>
26 struct ArcConstness : std::integral_constant<bool, Constness>
27 {
28 };
31 
33 template<bool OutgoingDirection>
34 struct ArcDirection : std::integral_constant<bool, OutgoingDirection>
35 {
36 };
39 
40 // Forward-declare the arc adaptor classes:
41 template<typename TraitsType>
43 template<typename TraitsType, typename Const, typename Outgoing>
45 
52 template<typename ArcTraits>
54 {
55 public:
56  using Traits = ArcTraits; // Allow classes to inspect our input parameter.
57 
59  using Directed = typename ArcTraits::Directed;
61  using FromType = typename ArcTraits::FromType;
63  using ToType = typename ArcTraits::ToType;
76 
78  static constexpr std::size_t MinOutDegree = minOutDegree<ArcTraits>(unconstrained());
80  static constexpr std::size_t MinInDegree = minInDegree<ArcTraits>(unconstrained());
82  static constexpr std::size_t MaxOutDegree = maxOutDegree<ArcTraits>(unconstrained());
84  static constexpr std::size_t MaxInDegree = maxInDegree<ArcTraits>(unconstrained());
85  static_assert(
86  Directed::value || !std::is_same<FromType, ToType>::value ||
88  R"(
89  Undirected arcs with identical From/To types must
90  have identical in- and out-degree constraints.)");
91 
93  bool isOrdered() const { return Ordered::value; }
94 
96  bool isDirected() const { return Directed::value; }
97 
99  bool isMutable() const { return Mutable::value; }
100 
102  bool isExplicit() const { return Explicit::value; }
103 
107  template<
109  typename U = typename ArcProperties<Traits>::template hasContains<
111  typename std::enable_if<!U::value, bool>::type contains(const FromType* from, const ToType* to)
112  const
113  {
114  // Provide a (slow) implementation for arc types
115  // that do not provide their own (fast) implementation.
116  bool result = false;
117  if (!from)
118  {
119  return result;
120  }
121  this->outVisitor(from, [&result, &to](const ToType* node) {
122  if (node == to)
123  {
124  result = true;
126  }
128  });
129  return result;
130  };
131 
132  template<
133  typename U = typename ArcProperties<Traits>::template hasContains<
135  typename std::enable_if<U::value, bool>::type contains(const FromType* from, const ToType* to)
136  const
137  {
138  bool result = m_data.contains(from, to);
139  return result;
140  };
142 
152  template<
154  typename U = typename ArcProperties<Traits>::template hasOutNodeVisitor<
156  typename ResourcePtr,
157  typename Functor>
158  typename std::enable_if<!U::value, smtk::common::Visited>::type visitAllOutgoingNodes(
159  ResourcePtr rsrc,
160  Functor ff) const
161  {
162  // Provide a (slow) implementation for arc types
163  // that do not provide their own (fast) implementation.
165  if (!rsrc)
166  {
167  return result;
168  }
170  // FIXME: The default resource visitor does not allow early termination.
171  std::function<void(const std::shared_ptr<smtk::resource::Component>&)> compVisitor =
172  [&](const smtk::resource::ComponentPtr& component) {
173  if (const auto* node = dynamic_cast<const typename Traits::FromType*>(component.get()))
174  {
175  nodeVisitor(node);
176  }
177  };
178  rsrc->visit(compVisitor);
180  return result;
181  };
182 
183  template<
184  typename U = typename ArcProperties<Traits>::template hasOutNodeVisitor<
186  typename ResourcePtr,
187  typename Functor>
188  typename std::enable_if<U::value, smtk::common::Visited>::type visitAllOutgoingNodes(
189  ResourcePtr rsrc,
190  Functor ff) const
191  {
192  smtk::common::Visited result = m_data.visitAllOutgoingNodes(rsrc, ff);
193  return result;
194  };
196 
206  template<
208  typename U = typename ArcProperties<Traits>::template hasInNodeVisitor<
210  typename ResourcePtr,
211  typename Functor>
212  typename std::enable_if<!U::value, smtk::common::Visited>::type visitAllIncomingNodes(
213  ResourcePtr rsrc,
214  Functor ff) const
215  {
216  // Provide a (slow) implementation for arc types
217  // that do not provide their own (fast) implementation.
219  if (!rsrc)
220  {
221  return result;
222  }
224  // FIXME: The default resource visitor does not allow early termination.
225  std::function<void(const std::shared_ptr<smtk::resource::Component>&)> compVisitor =
226  [&](const smtk::resource::ComponentPtr& component) {
227  if (const auto* node = dynamic_cast<const typename Traits::ToType*>(component.get()))
228  {
229  nodeVisitor(node);
230  }
231  };
232  rsrc->visit(compVisitor);
234  return result;
235  };
236 
237  template<
238  typename U = typename ArcProperties<Traits>::template hasInNodeVisitor<
240  typename ResourcePtr,
241  typename Functor>
242  typename std::enable_if<U::value, smtk::common::Visited>::type visitAllIncomingNodes(
243  ResourcePtr rsrc,
244  Functor ff) const
245  {
246  smtk::common::Visited result = m_data.visitAllIncomingNodes(rsrc, ff);
247  return result;
248  };
250 
260  template<typename U = Mutable>
262  typename std::enable_if<!U::value, bool>::type connect(
263  const FromType* from,
264  const ToType* to,
265  const FromType* beforeFrom = nullptr,
266  const ToType* beforeTo = nullptr)
267  {
268  (void)from;
269  (void)to;
270  (void)beforeFrom;
271  (void)beforeTo;
272  return false;
273  }
274 
275  template<typename U = Mutable>
276  typename std::enable_if<U::value, bool>::type connect(
277  const FromType* from,
278  const ToType* to,
279  const FromType* beforeFrom = nullptr,
280  const ToType* beforeTo = nullptr)
281  {
282  bool result = m_data.connect(from, to, beforeFrom, beforeTo);
283  return result;
284  }
286 
290  template<typename U = Mutable>
292  typename std::enable_if<!U::value, bool>::type disconnect(const FromType* from, const ToType* to)
293  {
294  (void)from;
295  (void)to;
296  return false;
297  }
298 
299  template<typename U = Mutable>
300  typename std::enable_if<U::value, bool>::type disconnect(const FromType* from, const ToType* to)
301  {
302  bool result = m_data.disconnect(from, to);
303  return result;
304  }
306 
308  template<typename Functor>
309  smtk::common::Visited outVisitor(const FromType* from, Functor visitor) const
310  {
311  return m_data.outVisitor(from, visitor);
312  }
313 
316  template<
318  typename U = typename ArcProperties<Traits>::template hasOutDegree<
320  typename V =
322  typename std::enable_if<!U::value && !V::value, std::size_t>::type outDegree(
323  const FromType* from) const
324  {
325  // Provide a (slow) implementation for arc types
326  // that do not provide their own (fast) implementation (in
327  // the case where arcs are **not** auto-undirected).
328  std::size_t result = 0;
329  if (!from)
330  {
331  return result;
332  }
333  this->outVisitor(from, [&result](const ToType*) { ++result; });
334  return result;
335  };
336 
337  template<
338  typename U = typename ArcProperties<Traits>::template hasOutDegree<
340  typename V =
342  typename std::enable_if<!U::value && V::value, std::size_t>::type outDegree(
343  const FromType* from) const
344  {
345  // Provide a (slow) implementation for arc types
346  // that do not provide their own (fast) implementation (in
347  // the case where arcs **are** auto-undirected).
348  std::size_t result = 0;
349  if (!from)
350  {
351  return result;
352  }
353  this->outVisitor(from, [&result](const ToType*) { ++result; });
354  // Auto-undirected arcs may have to/from nodes flipped... look
355  // for \a from in the reverse map. We are guaranteed to have
356  // an in-visitor for undirected arcs.
357  this->inVisitor(
358  reinterpret_cast<const ToType*>(from), [&result](const FromType*) { ++result; });
359 
360  return result;
361  };
362 
363  template<
364  typename U = typename ArcProperties<Traits>::template hasOutDegree<
366  typename std::enable_if<U::value, std::size_t>::type outDegree(const FromType* from) const
367  {
368  std::size_t result = m_data.outDegree(from);
369  return result;
370  };
372 
375  template<
377  typename U = typename ArcProperties<Traits>::template hasInDegree<
379  typename V =
381  typename std::enable_if<!U::value && !V::value, std::size_t>::type inDegree(
382  const ToType* to) const
383  {
384  // Provide a (slow) implementation for arc types
385  // that do not provide their own (fast) implementation (in
386  // the case where arcs are **not** auto-undirected).
387  std::size_t result = 0;
388  if (!to)
389  {
390  return result;
391  }
392  this->inVisitor(to, [&result](const FromType*) { ++result; });
393  return result;
394  };
395 
396  template<
397  typename U = typename ArcProperties<Traits>::template hasInDegree<
399  typename V =
401  typename std::enable_if<!U::value && V::value, std::size_t>::type inDegree(const ToType* to) const
402  {
403  // Provide a (slow) implementation for arc types
404  // that do not provide their own (fast) implementation (in
405  // the case where arcs **are** auto-undirected).
406  std::size_t result = 0;
407  if (!to)
408  {
409  return result;
410  }
411  this->inVisitor(to, [&result](const ToType*) { ++result; });
412  // Auto-undirected arcs may have to/from nodes flipped... look
413  // for \a to in the reverse map. We are guaranteed to have
414  // an in-visitor for undirected arcs.
415  this->inVisitor(reinterpret_cast<const ToType*>(to), [&result](const ToType*) { ++result; });
416 
417  return result;
418  };
419 
420  template<
421  typename U = typename ArcProperties<Traits>::template hasInDegree<
423  typename std::enable_if<U::value, std::size_t>::type inDegree(const ToType* to) const
424  {
425  std::size_t result = m_data.inDegree(to);
426  return result;
427  };
429 
430 protected:
431  // Only implement inVisitor for ArcTraits that are bidirectional.
432  template<
433  typename Functor,
435  smtk::common::Visited inVisitorDetail(const ToType* to, Functor visitor) const
436  {
437  return m_data.inVisitor(to, visitor);
438  }
439 
440 public:
447  template<typename Functor>
448  smtk::common::Visited inVisitor(const ToType* to, Functor visitor) const
449  {
450  return this->inVisitorDetail<Functor, true>(to, visitor);
451  }
452 
455  {
457  }
459  {
461  }
462 
465  {
467  }
469  {
471  }
472 
473 protected:
484 };
485 
495 template<typename TraitsType, typename Const, typename Outgoing>
497 {
498 public:
499  using Traits = TraitsType;
500  using FromType = typename TraitsType::FromType;
501  using ToType = typename TraitsType::ToType;
502  using Directed = typename TraitsType::Directed;
503  using Mutable = typename ArcProperties<TraitsType>::isMutable;
504  using Ordered = typename ArcProperties<TraitsType>::isOrdered;
505  using ImplType = ArcImplementation<TraitsType>;
506  using ThisType = typename std::
507  conditional<Outgoing::value, typename ImplType::FromType, typename ImplType::ToType>::type;
508  using OtherType = typename std::
509  conditional<Outgoing::value, typename ImplType::ToType, typename ImplType::FromType>::type;
510  using Constness = Const;
512 
513  // Prevent this template from being realized when the arc Traits are only forward-indexed.
514  static_assert(Outgoing::value || !ArcProperties<Traits>::isOnlyForwardIndexed::value, R"(
515  This arc type is not indexed for reverse lookups.
516  )");
517 
522  : m_arcs(nullptr)
523  , m_endpoint(nullptr)
524  {
525  }
526 
527  // Provide a default copy constructor.
529 
530  // Return constraints on the degree of this endpoint's arcs:
531  constexpr std::size_t maxDegree() const
532  {
533  return Outgoing::value ? maxOutDegree<Traits>(unconstrained())
534  : maxInDegree<Traits>(unconstrained());
535  }
536  constexpr std::size_t minDegree() const
537  {
538  return Outgoing::value ? minOutDegree<Traits>(unconstrained())
539  : minInDegree<Traits>(unconstrained());
540  }
541 
542 protected:
543  template<bool Outgoingness, typename Functor>
545  {
546  smtk::common::Visited operator()(const SelfEndpoint* self, Functor visitor) const
547  {
548  return self->m_arcs->outVisitor(self->m_endpoint, visitor);
549  }
550  };
551 
552  template<typename Functor>
553  struct VisitEndpoints<false, Functor>
554  {
555  smtk::common::Visited operator()(const SelfEndpoint* self, Functor visitor) const
556  {
557  return self->m_arcs->inVisitor(self->m_endpoint, visitor);
558  }
559  };
560 
561  template<bool Outgoingness, int Dummy = 0>
563  {
564  bool operator()(const SelfEndpoint* self, const ToType* endpoint) const
565  {
566  return self->m_arcs->contains(self->m_endpoint, endpoint);
567  }
568  };
569 
570  template<int Dummy>
571  struct ContainsEndpoint<false, Dummy>
572  {
573  bool operator()(const SelfEndpoint* self, const FromType* endpoint) const
574  {
575  return self->m_arcs->contains(endpoint, self->m_endpoint);
576  }
577  };
578 
579  // Provide a functor for computing degree.
580  // The default implementation is for outgoing arcs (i.e., outDegree).
581  template<bool Outgoingness, int Dummy = 0>
582  struct Degree
583  {
584  std::size_t operator()(const SelfEndpoint* self) const
585  {
586  return self->m_arcs->outDegree(self->m_endpoint);
587  }
588  };
589 
590  // Specialize the above for incoming degree (inDegree).
591  template<int Dummy>
592  struct Degree<false, Dummy>
593  {
594  std::size_t operator()(const SelfEndpoint* self) const
595  {
596  return self->m_arcs->inDegree(self->m_endpoint);
597  }
598  };
599 
600 public:
602  template<typename Functor>
603  smtk::common::Visited visit(Functor visitor) const
604  {
605  return VisitEndpoints<Outgoing::value, Functor>()(this, visitor);
606  }
607 
609  bool contains(const OtherType* node) const
610  {
611  return ContainsEndpoint<Outgoing::value>()(this, node);
612  }
613 
618  std::size_t degree() const
620  {
621  std::size_t dd = Degree<Outgoing::value>()(this);
622  return dd;
623  }
624  std::size_t size() const { return this->degree(); }
626 
628  bool empty() const { return this->size() == 0; }
629 
641  const OtherType* node() const
642  {
643  const OtherType* result = nullptr;
644  this->visit([&result](const OtherType* node) {
645  result = node;
647  });
648  return result;
649  }
650 
652  const OtherType* front() const { return this->node(); }
653 
656 
657 protected:
658  template<bool Mutability, bool Outgoingness, int Dummy = 0>
659  struct Connector
660  {
661  bool operator()(
662  SelfEndpoint* self,
663  const OtherType* other,
664  const OtherType* beforeOther = nullptr,
665  const ThisType* beforeThis = nullptr) const
666  {
667  return self->m_arcs->connect(self->m_endpoint, other, beforeThis, beforeOther);
668  }
669  };
670 
671  template<int Dummy>
672  struct Connector<true, false, Dummy>
673  {
674  bool operator()(
675  SelfEndpoint* self,
676  const OtherType* other,
677  const OtherType* beforeOther = nullptr,
678  const ThisType* beforeThis = nullptr) const
679  {
680  return self->m_arcs->connect(other, self->m_endpoint, beforeOther, beforeThis);
681  }
682  };
683 
684  // Provide an implementation for immutable arcs that rejects all edits.
685  template<bool Outgoingness, int Dummy>
686  struct Connector<false, Outgoingness, Dummy>
687  {
688  bool operator()(
689  SelfEndpoint* self,
690  const OtherType* other,
691  const OtherType* beforeOther = nullptr,
692  const ThisType* beforeThis = nullptr) const
693  {
694  (void)self;
695  (void)other;
696  (void)beforeOther;
697  (void)beforeThis;
698  return false;
699  }
700  };
701 
702  template<bool Mutability, bool Outgoingness, int Dummy = 0>
704  {
705  bool operator()(SelfEndpoint* self, const OtherType* other) const
706  {
707  return self->m_arcs->disconnect(self->m_endpoint, other);
708  }
709  };
710 
711  template<int Dummy>
712  struct Disconnector<true, false, Dummy>
713  {
714  bool operator()(SelfEndpoint* self, const OtherType* other) const
715  {
716  return self->m_arcs->disconnect(other, self->m_endpoint);
717  }
718  };
719 
720  template<bool Outgoingness, int Dummy>
721  struct Disconnector<false, Outgoingness, Dummy>
722  {
723  bool operator()(SelfEndpoint* self, const OtherType* other) const
724  {
725  (void)self;
726  (void)other;
727  return false;
728  }
729  };
730 
731 public:
733  bool connect(const OtherType* other)
734  {
735  static_assert(!Constness::value, "A const-referenced node may not be edited.");
736  return Connector<Mutable::value, Outgoing::value>()(this, other);
737  }
738 
740  bool connect(const std::shared_ptr<OtherType>& other) { return this->connect(other.get()); }
741 
743  bool insert(
744  const OtherType* other,
745  const OtherType* beforeOther = nullptr,
746  const ThisType* beforeThis = nullptr)
747  {
748  static_assert(!Constness::value, "A const-referenced node may not be edited.");
749  return Connector<Mutable::value, Outgoing::value>()(this, other, beforeThis, beforeOther);
750  }
751 
753  bool disconnect(const OtherType* other)
754  {
755  static_assert(!Constness::value, "A const-referenced node may not be edited.");
756  return Disconnector<Mutable::value, Outgoing::value>()(this, other);
757  }
758  bool erase(const OtherType* other)
759  {
760  static_assert(!Constness::value, "A const-referenced node may not be edited.");
761  return Disconnector<Mutable::value, Outgoing::value>()(this, other);
762  }
764  bool disconnect(const std::shared_ptr<OtherType>& other) { return this->disconnect(other.get()); }
766  bool erase(const std::shared_ptr<OtherType>& other) { return this->erase(other.get()); }
767 
769 
772  // template<typename Container>
773  // typename std::enable_if<!Const::value, bool>::type
774  // operator = (const Container& destNodes);
775 
776 protected:
777  friend class ArcImplementation<TraitsType>;
778 
780  const ArcImplementation<TraitsType>* arcs,
781  typename std::conditional<Const::value, const ThisType*, ThisType*>::type endpoint)
782  : m_arcs(const_cast<ArcImplementation<TraitsType>*>(arcs))
783  , m_endpoint(endpoint)
784  {
785  }
786 
788  typename std::conditional<Const::value, const ThisType*, ThisType*>::type m_endpoint;
789 };
790 
791 } // namespace graph
792 } // namespace smtk
793 
794 #endif // smtk_graph_ArcImplementation_h
smtk
The main namespace for the Simulation Modeling Tool Kit (SMTK).
Definition: doc.h:33
smtk::graph::ArcImplementation::outgoing
ArcEndpointInterface< ArcTraits, ConstArc, OutgoingArc > outgoing(const FromType *from) const
Return a "container" of outgoing arcs of the given from node.
Definition: ArcImplementation.h:454
smtk::graph::ArcEndpointInterface::front
const OtherType * front() const
STL-container synonym for node():
Definition: ArcImplementation.h:652
smtk::graph::ArcEndpointInterface::erase
bool erase(const OtherType *other)
Connect the other node to this node.
Definition: ArcImplementation.h:758
smtk::common::Visit::Halt
@ Halt
Stop visiting items immediately.
smtk::graph::ArcEndpointInterface::connect
bool connect(const OtherType *other)
Connect the other node to this node.
Definition: ArcImplementation.h:733
smtk::graph::ArcImplementation::m_data
detail::SelectArcContainer< ArcTraits, ArcTraits > m_data
Store arc endpoint data.
Definition: ArcImplementation.h:483
smtk::graph::ArcProperties::isOrdered
True when the order in which arcs are stored is significant.
Definition: ArcProperties.h:206
smtk::graph::ArcImplementation::inDegree
std::enable_if<!U::value &&!V::value, std::size_t >::type inDegree(const ToType *to) const
Compute the in-degree of the node.
Definition: ArcImplementation.h:381
smtk::graph::ArcImplementation::visitAllOutgoingNodes
std::enable_if< U::value, smtk::common::Visited >::type visitAllOutgoingNodes(ResourcePtr rsrc, Functor ff) const
Visit all nodes which have outgoing arcs of this type.
Definition: ArcImplementation.h:188
smtk::graph::ArcImplementation::inVisitor
smtk::common::Visited inVisitor(const ToType *to, Functor visitor) const
Visit nodes attached via incoming arcs.
Definition: ArcImplementation.h:448
smtk::common::Visited::All
@ All
The visitor was invoked on every item exhaustively.
smtk::graph::ArcImplementation< TraitsType >::ToType
typename TraitsType ::ToType ToType
The type of node that these arcs point to.
Definition: ArcImplementation.h:63
smtk::graph::ArcImplementation::isMutable
bool isMutable() const
Return whether arcs of this type may be edited.
Definition: ArcImplementation.h:99
smtk::common::Visited::Empty
@ Empty
The were no values to visit.
smtk::graph::ArcImplementation::MinInDegree
static constexpr std::size_t MinInDegree
The minimum in-degree of a ToType node. This is not enforced.
Definition: ArcImplementation.h:80
smtk::graph::ArcEndpointInterface::ContainsEndpoint
Definition: ArcImplementation.h:562
smtk::graph::ArcImplementation::outDegree
std::enable_if< U::value, std::size_t >::type outDegree(const FromType *from) const
Compute the out-degree of the node.
Definition: ArcImplementation.h:366
smtk::graph::ArcDirection
For endpoint interfaces, provide tag classes used to select incoming or outgoing APIs.
Definition: ArcImplementation.h:34
smtk::graph::ArcEndpointInterface::insert
bool insert(const OtherType *other, const OtherType *beforeOther=nullptr, const ThisType *beforeThis=nullptr)
Insert a new arc connecting this endpoint to the other.
Definition: ArcImplementation.h:743
smtk::graph::ArcEndpointInterface::degree
std::size_t degree() const
Return the number of arcs of this type that terminate at this endpoint.
Definition: ArcImplementation.h:619
smtk::graph::ArcImplementation::disconnect
std::enable_if<!U::value, bool >::type disconnect(const FromType *from, const ToType *to)
Remove an arc from from to to.
Definition: ArcImplementation.h:292
smtk::graph::ArcEndpointInterface::erase
bool erase(const std::shared_ptr< OtherType > &other)
A convenience version of erase() that accepts shared pointers.
Definition: ArcImplementation.h:766
smtk::graph::ArcEndpointInterface::disconnect
bool disconnect(const OtherType *other)
Disconnect the other node from this one (i.e., erase an arc).
Definition: ArcImplementation.h:753
smtk::graph::ArcEndpointInterface::contains
bool contains(const OtherType *node) const
Return true if this endpoint is connected to node.
Definition: ArcImplementation.h:609
smtk::graph::ArcEndpointInterface::empty
bool empty() const
Return whether this endpoint has zero arcs.
Definition: ArcImplementation.h:628
smtk::graph::ArcImplementation< TraitsType >::Directed
typename TraitsType ::Directed Directed
If "truthy," this arc is considered directed rather than undirected.
Definition: ArcImplementation.h:59
smtk::graph::ArcProperties::isMutable
Check whether the arc traits object (1) is implicit and has methods to insert and remove arcs; or (2)...
Definition: ArcProperties.h:253
smtk::graph::ArcEndpointInterface::Disconnector
Definition: ArcImplementation.h:703
smtk::graph::ArcImplementation< TraitsType >::FromType
typename TraitsType ::FromType FromType
The type of node that these arcs originate from.
Definition: ArcImplementation.h:61
smtk::graph::ArcEndpointInterface::Connector
Edit methods (only enabled for non-const interfaces).
Definition: ArcImplementation.h:659
smtk::graph::ArcEndpointInterface
An object that a node instance can present to access/edit its outgoing/incoming arcs.
Definition: ArcImplementation.h:44
smtk::graph::ArcImplementation::MaxInDegree
static constexpr std::size_t MaxInDegree
The maximum in-degree of a ToType node. This is enforced.
Definition: ArcImplementation.h:84
smtk::graph::ArcProperties
Checks that can be performed on arc trait-types.
Definition: ArcProperties.h:42
smtk::graph::ArcImplementation::inDegree
std::enable_if<!U::value &&V::value, std::size_t >::type inDegree(const ToType *to) const
Compute the in-degree of the node.
Definition: ArcImplementation.h:401
smtk::graph::ArcEndpointInterface::ArcEndpointInterface
ArcEndpointInterface()
This is a dummy constructor that is not used by valid code.
Definition: ArcImplementation.h:521
smtk::common::Visit::Continue
@ Continue
Continue to visit items.
smtk::graph::ArcImplementation::contains
std::enable_if< U::value, bool >::type contains(const FromType *from, const ToType *to) const
Test whether an arc from from to to exists.
Definition: ArcImplementation.h:135
smtk::graph::ArcEndpointInterface::disconnect
bool disconnect(const std::shared_ptr< OtherType > &other)
A convenience version of disconnect() that accepts shared pointers.
Definition: ArcImplementation.h:764
smtk::graph::ArcConstness
For endpoint interfaces, provide tag classes used to select const or non-const APIs.
Definition: ArcImplementation.h:26
smtk::graph::ArcEndpointInterface::Degree
Definition: ArcImplementation.h:582
smtk::graph::ArcImplementation::outDegree
std::enable_if<!U::value &&V::value, std::size_t >::type outDegree(const FromType *from) const
Compute the out-degree of the node.
Definition: ArcImplementation.h:342
smtk::graph::ArcImplementation::visitAllIncomingNodes
std::enable_if<!U::value, smtk::common::Visited >::type visitAllIncomingNodes(ResourcePtr rsrc, Functor ff) const
Visit all nodes which have incoming arcs of this type.
Definition: ArcImplementation.h:212
smtk::graph::ArcImplementation::outVisitor
smtk::common::Visited outVisitor(const FromType *from, Functor visitor) const
Visit nodes attached via outgoing arcs.
Definition: ArcImplementation.h:309
smtk::graph::ArcEndpointInterface::node
const OtherType * node() const
Return the first destination endpoint.
Definition: ArcImplementation.h:641
smtk::graph::ArcEndpointInterface::size
std::size_t size() const
Return the number of arcs of this type that terminate at this endpoint.
Definition: ArcImplementation.h:624
smtk::graph::ArcImplementation::isOrdered
bool isOrdered() const
Return whether arcs of this type are ordered (true) or unordered (false).
Definition: ArcImplementation.h:93
smtk::graph::ArcImplementation::isDirected
bool isDirected() const
Return whether arcs of this type are directed (true) or undirected (false).
Definition: ArcImplementation.h:96
smtk::graph::ArcImplementation::isExplicit
bool isExplicit() const
Return whether arcs of this type are explicit.
Definition: ArcImplementation.h:102
smtk::graph::ArcImplementation::visitAllIncomingNodes
std::enable_if< U::value, smtk::common::Visited >::type visitAllIncomingNodes(ResourcePtr rsrc, Functor ff) const
Visit all nodes which have incoming arcs of this type.
Definition: ArcImplementation.h:242
smtk::graph::ArcEndpointInterface::visit
smtk::common::Visited visit(Functor visitor) const
Visit nodes attached to the endpoint by arcs of this type.
Definition: ArcImplementation.h:603
smtk::graph::ArcImplementation::inDegree
std::enable_if< U::value, std::size_t >::type inDegree(const ToType *to) const
Compute the in-degree of the node.
Definition: ArcImplementation.h:423
smtk::graph::maxInDegree
constexpr std::enable_if< std::is_integral< decltype(T::MaxInDegree)>::value, std::size_t >::type maxInDegree(std::size_t)
Return the maximum in-degree of an arc type (or unconstrained() if unspecified).
Definition: ArcProperties.h:305
smtk::graph::ArcImplementation
A wrapper around arc type-traits classes that provides API.
Definition: ArcImplementation.h:42
smtk::common::Visited
Visited
Return value for functions/methods that accept visitors.
Definition: Visit.h:35
smtk::graph::ArcImplementation::visitAllOutgoingNodes
std::enable_if<!U::value, smtk::common::Visited >::type visitAllOutgoingNodes(ResourcePtr rsrc, Functor ff) const
Visit all nodes which have outgoing arcs of this type.
Definition: ArcImplementation.h:158
smtk::graph::unconstrained
constexpr std::size_t unconstrained()
Return a constant used to indicate the maximimum degree of an arc endpoint is unconstrained.
Definition: ArcProperties.h:29
smtk::graph::ArcImplementation::MaxOutDegree
static constexpr std::size_t MaxOutDegree
The maximum out-degree of a FromType node. This is enforced.
Definition: ArcImplementation.h:82
smtk::graph::ArcImplementation< TraitsType >::Ordered
typename ArcProperties< TraitsType >::isOrdered Ordered
If "truthy," this arc will report incoming/outgoing nodes in a (user-specified) order.
Definition: ArcImplementation.h:65
smtk::graph::ArcProperties::isExplicit
False when an arc class provides implementations of required methods; true otherwise.
Definition: ArcProperties.h:242
smtk::graph::ArcImplementation::outDegree
std::enable_if<!U::value &&!V::value, std::size_t >::type outDegree(const FromType *from) const
Compute the out-degree of the node.
Definition: ArcImplementation.h:322
smtk::graph::minInDegree
constexpr std::enable_if< std::is_integral< decltype(T::MinInDegree)>::value, std::size_t >::type minInDegree(std::size_t)
Return the minimum in-degree of an arc type (or 0 if unspecified).
Definition: ArcProperties.h:339
smtk::graph::ArcImplementation::MinOutDegree
static constexpr std::size_t MinOutDegree
The minimum out-degree of a FromType node. This is not enforced.
Definition: ArcImplementation.h:78
smtk::graph::ArcImplementation::incoming
ArcEndpointInterface< ArcTraits, ConstArc, IncomingArc > incoming(const ToType *to) const
Return a "container" of incoming arcs of the given to node.
Definition: ArcImplementation.h:464
smtk::graph::ArcEndpointInterface::VisitEndpoints
Definition: ArcImplementation.h:544
smtk::graph::ArcImplementation< TraitsType >::Explicit
typename ArcProperties< TraitsType >::isExplicit Explicit
If "truthy," arc endpoint connections are explicitly stored by SMTK.
Definition: ArcImplementation.h:75
Visit.h
smtk::graph::ArcEndpointInterface::connect
bool connect(const std::shared_ptr< OtherType > &other)
A convenience version of connect() that accepts shared pointers.
Definition: ArcImplementation.h:740
smtk::graph::ArcImplementation::disconnect
std::enable_if< U::value, bool >::type disconnect(const FromType *from, const ToType *to)
Remove an arc from from to to.
Definition: ArcImplementation.h:300
smtk::graph::ArcImplementation::contains
std::enable_if<!U::value, bool >::type contains(const FromType *from, const ToType *to) const
Test whether an arc from from to to exists.
Definition: ArcImplementation.h:111
smtk::graph::ArcImplementation::connect
std::enable_if<!U::value, bool >::type connect(const FromType *from, const ToType *to, const FromType *beforeFrom=nullptr, const ToType *beforeTo=nullptr)
Insert an arc from from to to, optionally ordered by beforeFrom and beforeTo.
Definition: ArcImplementation.h:262
smtk::graph::ArcImplementation< TraitsType >::Mutable
typename ArcProperties< TraitsType >::isMutable Mutable
If "truthy," methods that edit arcs may sometimes return true.
Definition: ArcImplementation.h:73
smtk::graph::ArcImplementation::connect
std::enable_if< U::value, bool >::type connect(const FromType *from, const ToType *to, const FromType *beforeFrom=nullptr, const ToType *beforeTo=nullptr)
Insert an arc from from to to, optionally ordered by beforeFrom and beforeTo.
Definition: ArcImplementation.h:276
smtk::resource::ComponentPtr
smtk::shared_ptr< smtk::resource::Component > ComponentPtr
Definition: PublicPointerDefs.h:297
smtk::graph::detail::SelectArcContainer
Provide no default arc storage.
Definition: TypeTraits.h:37
smtk::common::VisitorFunctor
A template for accepting visitors with different return types.
Definition: Visit.h:56