CFx SDK Documentation  2022 SP0
DbEvalGraph.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, Open Design Alliance (the "Alliance").
3 // All rights reserved.
4 //
5 // This software and its documentation and related materials are owned by
6 // the Alliance. The software may only be incorporated into application
7 // programs owned by members of the Alliance, subject to a signed
8 // Membership Agreement and Supplemental Software License Agreement with the
9 // Alliance. The structure and organization of this software are the valuable
10 // trade secrets of the Alliance and its suppliers. The software is also
11 // protected by copyright law and international treaty provisions. Application
12 // programs incorporating this software must include the following statement
13 // with their copyright notices:
14 //
15 // This application incorporates Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2017 by Open Design Alliance.
18 // All rights reserved.
19 //
20 // By use of this software, its documentation or related materials, you
21 // acknowledge and accept the above terms.
23 
24 #ifndef _DbEvalGraph_h_Included_
25 #define _DbEvalGraph_h_Included_
26 
27 #include "SmartPtr.h"
28 #include "DbObject.h"
29 
30 #include "TD_PackPush.h"
31 
32 // Forward class declarations
33 
34 class OdDbEvalGraph;
35 class OdDbEvalEdgeInfo;
36 class OdDbEvalExpr;
38 class OdDbEvalContext;
41 class OdResBuf;
42 class OdDbImpEvalContext;
43 class OdDbImpEvalContextIterator;
44 
49 
54 
59 
60 typedef unsigned long OdDbEvalNodeId;
61 
78 
79 #include "OdPlatformSettings.h"
80 #include "StringArray.h"
81 
82 #ifdef DYNBLOCKS_DLL_EXPORTS
83 #ifndef SWIG
84 #define DYNBLOCKS_EXPORT OD_TOOLKIT_EXPORT
85 #else
86 #define DYNBLOCKS_EXPORT
87 #endif
88 #define DYNBLOCKS_EXPORT_STATIC OD_STATIC_EXPORT
89 #else
90 #ifndef SWIG
91 #define DYNBLOCKS_EXPORT OD_TOOLKIT_IMPORT
92 #else
93 #define DYNBLOCKS_EXPORT
94 #endif
95 #define DYNBLOCKS_EXPORT_STATIC OD_STATIC_IMPORT
96 #endif
97 
122 {
123 public:
124 
125  enum NodeId {
126  kNullNodeId = 0
127  };
128 
130 
132  virtual ~OdDbEvalGraph();
133 
134  /* Management */
135 
141  static bool hasGraph(const OdDbObject* pObj,
142  const OdString& key);
143 
151  const OdString& pKey,
152  const OdDb::OpenMode openMode = OdDb::kForRead );
153 
154 
164  static bool createGraph(OdDbObject* pObj,
165  const OdString& key);
166 
167 
175  static bool removeGraph(OdDbObject* pObj,
176  const OdString& pKey);
177 
183  static bool hasGraph(OdDbDatabase* pDb,
184  const OdString& key);
185 
194  const OdString& key,
195  const OdDb::OpenMode openMode = OdDb::kForRead );
196 
206  static bool createGraph(OdDbDatabase* pDb,
207  const OdString& key);
208 
216  static bool removeGraph(OdDbDatabase* pDb,
217  const OdString& key);
218 
230 
238  virtual bool removeNode (const OdDbEvalNodeId& nodeId);
239 
247  virtual bool removeNode (OdDbEvalExpr* pNode);
248 
253  virtual void getAllNodes (OdDbEvalNodeIdArray& allNodes) const;
254 
260  virtual OdDbEvalExprPtr getNode( const OdDbEvalNodeId& nodeId, OdDb::OpenMode openMode = OdDb::kForRead ) const;
261 
262 
275  virtual bool addEdge(const OdDbEvalNodeId& idFrom,
276  const OdDbEvalNodeId& idTo);
277 
289  virtual bool addEdge(const OdDbEvalNodeId& idFrom,
290  const OdDbEvalNodeId& idTo,
291  bool invertible);
292 
293 
306  virtual bool removeEdge(const OdDbEvalNodeId& idFrom,
307  const OdDbEvalNodeId& idTo);
308 
315  virtual void getIncomingEdges(const OdDbEvalNodeId& nodeId,
316  OdDbEvalEdgeInfoArray& edges) const;
317 
324  virtual void getOutgoingEdges(const OdDbEvalNodeId& nodeId,
325  OdDbEvalEdgeInfoArray& edges) const;
326 
327 
336  virtual bool getEdgeInfo(const OdDbEvalNodeId& idFrom,
337  const OdDbEvalNodeId& idTo, OdDbEvalEdgeInfo& edgeInfo) const;
338 
339 
344  virtual void addGraph(OdDbEvalGraph* pGraphToAdd);
345 
346  /* Evaluation */
347 
364  virtual bool evaluate() const;
365 
371  virtual bool evaluate(
372  const OdDbEvalContext* pContext) const;
373 
380  virtual bool evaluate(
381  const OdDbEvalContext* pContext,
382  const OdDbEvalNodeIdArray* pActivateNodes) const;
383 
384 
396  virtual bool activate(
397  const OdDbEvalNodeIdArray& activatedNodes) const;
398 
399 
406  virtual bool activate(
407  const OdDbEvalNodeIdArray& activatedNodes,
408  OdDbEvalNodeIdArray* pActiveSubgraph) const;
409 
415  virtual bool activate(
416  const OdDbEvalNodeIdArray& activatedNodes,
417  OdDbEvalNodeIdArray* pActiveSubgraph,
418  OdDbEvalNodeIdArray* pCycleNodes) const;
419 
420 
430  virtual bool getIsActive(const OdDbEvalNodeId& nodeId,
431  bool& isActive) const;
432 
443  virtual bool equals(const OdDbEvalGraph* pOther) const;
444 
445 
451  virtual bool isSubgraphOf(const OdDbEvalGraph* pOther) const;
452 
454  virtual void dwgOutFields(OdDbDwgFiler* pFiler) const ODRX_OVERRIDE;
456  virtual void dxfOutFields(OdDbDxfFiler* pFiler) const ODRX_OVERRIDE;
457  virtual void applyPartialUndo(OdDbDwgFiler* pFiler, OdRxClass* pClassObj) ODRX_OVERRIDE;
458  virtual void copyFrom(const OdRxObject* p) ODRX_OVERRIDE;
460  virtual void subHandOverTo(
461  OdDbObject* pNewObject) ODRX_OVERRIDE;
462 };
463 
464 
480 {
481 public:
483  : mFlags(0), mRefCount(0)
484  {
485  mIdFrom = OdDbEvalGraph::kNullNodeId;
487  }
488 
495  OdDbEvalNodeId toId,
496  long flags,
497  unsigned long count)
498  : mIdFrom(fromId), mIdTo(toId), mFlags(flags), mRefCount(count)
499  {}
500 
505 
509  OdDbEvalNodeId to () const;
513  unsigned long refCount() const;
514 
521  bool isInvertible () const;
528  bool isSuppressed () const;
529 
530  bool operator == (const OdDbEvalEdgeInfo& other) const;
531 
532 private:
533  OdDbEvalNodeId mIdFrom;
534  OdDbEvalNodeId mIdTo;
535  long mFlags;
536  unsigned long mRefCount;
537 };
538 
539 
559 {
560 public:
562 
564  virtual ~OdDbEvalExpr();
565 
575 
585 
596  virtual void addedToGraph (OdDbEvalGraph* pGraph);
597 
608  virtual void removedFromGraph (OdDbEvalGraph* pGraph);
609 
610 
622  virtual void adjacentNodeRemoved (const OdDbEvalNodeId& adjNodeId);
623 
624 
635  virtual void adjacentEdgeRemoved (const OdDbEvalNodeId& adjEdgeNodeId);
636 
637 
651  virtual void adjacentEdgeAdded (const OdDbEvalNodeId& fromId,
652  const OdDbEvalNodeId& toId,
653  bool isInvertible);
654 
655 
667  virtual void movedFromGraph (OdDbEvalGraph* pFromGraph);
668 
680  virtual void movedIntoGraph (OdDbEvalGraph* pIntoGraph);
681 
682 
683 
695  virtual void copiedIntoGraph(OdDbEvalGraph* pIntoGraph);
696 
703  virtual bool isActivatable () const;
704 
717  virtual void activated (OdDbEvalNodeIdArray& argumentActiveList);
718 
729  virtual void graphEvalStart (bool nodeIsActive);
730 
731 
742  virtual void graphEvalEnd(bool nodeIsActive);
743 
754  virtual void graphEvalAbort(bool nodeIsActive);
755 
767  virtual bool evaluate(const OdDbEvalContext* evalContext);
768 
777  virtual bool equals(const OdDbEvalExpr* pOther) const;
778 
785 
787  void dwgOutFields(OdDbDwgFiler* pFiler) const;
789  void dxfOutFields(OdDbDxfFiler* pFiler) const;
791 
792 protected:
793 
795  friend class OdDbEvalExprImpl;
796 };
797 
798 
814 {
815 public:
817 
819 
824  virtual void getConnectionNames (OdStringArray& connectionNames) const;
825 
830  virtual bool hasConnectionNamed (const OdString& connectionName) const;
831 
832 
840  virtual bool getConnectionType (
841  const OdString& connectionName,
842  OdResBuf::ValueType& connectionType) const;
843 
844 
851  virtual OdResBufPtr getConnectionValue( const OdString& connectionName) const;
852 
853 
861  virtual bool setConnectionValue ( const OdString& connectionName, const OdResBuf* pValue);
862 
863 
876  virtual bool connectTo (
877  const OdString& thisConnectionName,
878  OdDbEvalNodeId sourceConnectableId,
879  const OdString& sourceConnectionName);
880 
881 
894  virtual bool disconnectFrom (
895  const OdString& thisConnectionName,
896  OdDbEvalNodeId sourceConnectableId,
897  const OdString& sourceConnectionName);
898 
910  virtual bool connectionAllowed (
911  const OdString& thisConnectionName,
912  OdDbEvalNodeId sourceConnectableId,
913  const OdString& sourceConnectionName) const;
914 
915 
925  virtual bool getConnectedObjects (
926  const OdString& thisConnectionName,
927  OdDbEvalNodeIdArray& connectedObjects) const;
928 
939  virtual bool getConnectedNames (
940  const OdString& thisConnectionName,
941  OdDbEvalNodeId sourceConnectableId,
942  OdStringArray& sourceConnectionNames) const;
943 protected:
944 
946 };
947 
952 
972 {
973 public:
974 
976 
977 
978  virtual ~OdDbEvalContext();
979 
981 
982 
989  virtual void insertAt (const OdDbEvalContextPair& pair);
990 
991 
996  virtual void removeAt (const OdString& key);
997 
998 
1010  virtual bool getAt (OdDbEvalContextPair& pair) const;
1011 
1012 
1017 
1018 private:
1019  OdDbImpEvalContext* m_pImp;
1020  friend class OdDbImpEvalContextIterator;
1021 };
1022 
1042 {
1043 public:
1044 
1046 
1050  OdDbEvalContextPair(const OdString& key, void *value);
1051 
1053 
1058  void setKey (const OdString& key);
1059 
1064  const OdString key () const;
1065 
1073  void setValue (void* value);
1074 
1079  void* value () const;
1080 
1081 private:
1082  OdString mKey;
1083  void* mValue;
1084 };
1085 
1086 
1105 {
1106 public:
1108 
1110 
1112 
1119  virtual void start();
1120 
1124  virtual bool next();
1125 
1129  virtual bool done() const;
1130 
1135 
1136 private:
1137  OdDbImpEvalContextIterator* m_pImp;
1138  friend class OdDbImpEvalContext;
1139 };
1140 
1141 #include "TD_PackPop.h"
1142 
1143 #endif
OdArray< OdDbEvalEdgeInfo > OdDbEvalEdgeInfoArray
Definition: DbEvalGraph.h:69
OdSmartPtr< OdDbEvalConnectable > OdDbEvalConnectablePtr
Definition: DbEvalGraph.h:951
OdSmartPtr< OdDbEvalGraph > OdDbEvalGraphPtr
Definition: DbEvalGraph.h:43
OdArray< OdDbEvalNodeId, OdMemoryAllocator< OdDbEvalNodeId > > OdDbEvalNodeIdArray
Definition: DbEvalGraph.h:65
#define DYNBLOCKS_EXPORT
Definition: DbEvalGraph.h:91
OdArray< OdDbEvalExprPtr > OdDbEvalExprPtrArray
Definition: DbEvalGraph.h:73
OdSmartPtr< OdDbEvalContextIterator > OdDbEvalContextIteratorPtr
Definition: DbEvalGraph.h:53
unsigned long OdDbEvalNodeId
Definition: DbEvalGraph.h:60
OdSmartPtr< OdDbEvalExpr > OdDbEvalExprPtr
Definition: DbEvalGraph.h:58
OdArray< OdResBufPtr > OdResBufArray
Definition: DbEvalGraph.h:77
#define ODRX_OVERRIDE
OdResult
Definition: OdResult.h:29
virtual void getConnectionNames(OdStringArray &connectionNames) const
virtual bool disconnectFrom(const OdString &thisConnectionName, OdDbEvalNodeId sourceConnectableId, const OdString &sourceConnectionName)
virtual bool getConnectionType(const OdString &connectionName, OdResBuf::ValueType &connectionType) const
ODDB_DECLARE_MEMBERS(OdDbEvalConnectable)
virtual bool connectionAllowed(const OdString &thisConnectionName, OdDbEvalNodeId sourceConnectableId, const OdString &sourceConnectionName) const
virtual bool getConnectedObjects(const OdString &thisConnectionName, OdDbEvalNodeIdArray &connectedObjects) const
virtual bool hasConnectionNamed(const OdString &connectionName) const
virtual bool connectTo(const OdString &thisConnectionName, OdDbEvalNodeId sourceConnectableId, const OdString &sourceConnectionName)
virtual ~OdDbEvalConnectable()
virtual OdResBufPtr getConnectionValue(const OdString &connectionName) const
virtual bool getConnectedNames(const OdString &thisConnectionName, OdDbEvalNodeId sourceConnectableId, OdStringArray &sourceConnectionNames) const
virtual bool setConnectionValue(const OdString &connectionName, const OdResBuf *pValue)
virtual bool getAt(OdDbEvalContextPair &pair) const
virtual void insertAt(const OdDbEvalContextPair &pair)
virtual void removeAt(const OdString &key)
virtual OdDbEvalContextIteratorPtr newIterator() const
virtual ~OdDbEvalContext()
ODRX_DECLARE_MEMBERS(OdDbEvalContext)
virtual OdDbEvalContextPair contextPair() const
ODRX_DECLARE_MEMBERS(OdDbEvalContextIterator)
virtual bool done() const
virtual ~OdDbEvalContextIterator()
virtual void start()
void * value() const
const OdString key() const
OdDbEvalContextPair(const OdString &key, void *value)
virtual ~OdDbEvalContextPair()
void setKey(const OdString &key)
void setValue(void *value)
OdDbEvalNodeId from() const
bool isInvertible() const
OdDbEvalNodeId to() const
unsigned long refCount() const
OdDbEvalEdgeInfo(OdDbEvalNodeId fromId, OdDbEvalNodeId toId, long flags, unsigned long count)
Definition: DbEvalGraph.h:494
bool isSuppressed() const
virtual void activated(OdDbEvalNodeIdArray &argumentActiveList)
virtual void adjacentEdgeAdded(const OdDbEvalNodeId &fromId, const OdDbEvalNodeId &toId, bool isInvertible)
OdResBufPtr m_lastValue
Definition: DbEvalGraph.h:794
virtual void copiedIntoGraph(OdDbEvalGraph *pIntoGraph)
OdResult dwgInFields(OdDbDwgFiler *pFiler)
virtual void adjacentNodeRemoved(const OdDbEvalNodeId &adjNodeId)
virtual ~OdDbEvalExpr()
OdResult dxfInFields(OdDbDxfFiler *pFiler)
virtual void adjacentEdgeRemoved(const OdDbEvalNodeId &adjEdgeNodeId)
virtual void addedToGraph(OdDbEvalGraph *pGraph)
OdDbEvalNodeId nodeId() const
virtual void graphEvalEnd(bool nodeIsActive)
OdResBufPtr value() const
virtual bool isActivatable() const
OdDbEvalGraphPtr getGraph(OdDb::OpenMode openMode=OdDb::kForRead) const
virtual void movedFromGraph(OdDbEvalGraph *pFromGraph)
void dxfOutFields(OdDbDxfFiler *pFiler) const
virtual bool equals(const OdDbEvalExpr *pOther) const
void dwgOutFields(OdDbDwgFiler *pFiler) const
ODDB_DECLARE_MEMBERS(OdDbEvalExpr)
virtual OdResult postInDatabase(OdDbDatabase *)
virtual bool evaluate(const OdDbEvalContext *evalContext)
virtual void graphEvalAbort(bool nodeIsActive)
virtual void movedIntoGraph(OdDbEvalGraph *pIntoGraph)
virtual void graphEvalStart(bool nodeIsActive)
virtual void removedFromGraph(OdDbEvalGraph *pGraph)
virtual OdResult dwgInFields(OdDbDwgFiler *pFiler) ODRX_OVERRIDE
virtual bool isSubgraphOf(const OdDbEvalGraph *pOther) const
virtual bool activate(const OdDbEvalNodeIdArray &activatedNodes, OdDbEvalNodeIdArray *pActiveSubgraph, OdDbEvalNodeIdArray *pCycleNodes) const
virtual bool evaluate(const OdDbEvalContext *pContext, const OdDbEvalNodeIdArray *pActivateNodes) const
virtual void getOutgoingEdges(const OdDbEvalNodeId &nodeId, OdDbEvalEdgeInfoArray &edges) const
virtual bool addEdge(const OdDbEvalNodeId &idFrom, const OdDbEvalNodeId &idTo)
virtual bool activate(const OdDbEvalNodeIdArray &activatedNodes) const
virtual bool addEdge(const OdDbEvalNodeId &idFrom, const OdDbEvalNodeId &idTo, bool invertible)
static bool removeGraph(OdDbObject *pObj, const OdString &pKey)
virtual void getAllNodes(OdDbEvalNodeIdArray &allNodes) const
virtual bool getEdgeInfo(const OdDbEvalNodeId &idFrom, const OdDbEvalNodeId &idTo, OdDbEvalEdgeInfo &edgeInfo) const
virtual OdResult dxfInFields(OdDbDxfFiler *pFiler) ODRX_OVERRIDE
virtual bool equals(const OdDbEvalGraph *pOther) const
virtual ~OdDbEvalGraph()
virtual void dxfOutFields(OdDbDxfFiler *pFiler) const ODRX_OVERRIDE
virtual bool removeNode(const OdDbEvalNodeId &nodeId)
virtual bool getIsActive(const OdDbEvalNodeId &nodeId, bool &isActive) const
virtual void getIncomingEdges(const OdDbEvalNodeId &nodeId, OdDbEvalEdgeInfoArray &edges) const
virtual void addGraph(OdDbEvalGraph *pGraphToAdd)
virtual bool activate(const OdDbEvalNodeIdArray &activatedNodes, OdDbEvalNodeIdArray *pActiveSubgraph) const
virtual bool removeEdge(const OdDbEvalNodeId &idFrom, const OdDbEvalNodeId &idTo)
virtual OdDbEvalNodeId addNode(OdDbEvalExpr *pNode)
ODDB_DECLARE_MEMBERS(OdDbEvalGraph)
virtual void copyFrom(const OdRxObject *p) ODRX_OVERRIDE
virtual void subHandOverTo(OdDbObject *pNewObject) ODRX_OVERRIDE
static bool removeGraph(OdDbDatabase *pDb, const OdString &key)
static OdDbEvalGraphPtr getGraph(OdDbDatabase *pDb, const OdString &key, const OdDb::OpenMode openMode=OdDb::kForRead)
virtual OdDbEvalExprPtr getNode(const OdDbEvalNodeId &nodeId, OdDb::OpenMode openMode=OdDb::kForRead) const
virtual void applyPartialUndo(OdDbDwgFiler *pFiler, OdRxClass *pClassObj) ODRX_OVERRIDE
static bool createGraph(OdDbDatabase *pDb, const OdString &key)
virtual void dwgOutFields(OdDbDwgFiler *pFiler) const ODRX_OVERRIDE
virtual bool removeNode(OdDbEvalExpr *pNode)
virtual bool evaluate() const
static bool hasGraph(OdDbDatabase *pDb, const OdString &key)
virtual OdResult postInDatabase(OdDbDatabase *)
static OdDbEvalGraphPtr getGraph(const OdDbObject *pObj, const OdString &pKey, const OdDb::OpenMode openMode=OdDb::kForRead)
virtual bool evaluate(const OdDbEvalContext *pContext) const
static bool createGraph(OdDbObject *pObj, const OdString &key)
static bool hasGraph(const OdDbObject *pObj, const OdString &key)
ValueType
Definition: ResBuf.h:171
GLsizei GLsizei * count
Definition: gles2_ext.h:276
GLsizei const GLfloat * value
Definition: gles2_ext.h:302
bool DAI_EXPORT operator==(const OdFileDescriptionAuto &left, const OdFileDescriptionAuto &right)
OpenMode
Definition: DbObjectId.h:54
@ kForRead
Definition: DbObjectId.h:56