XdmfGraph.hpp 4.51 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/*****************************************************************************/
/*                                    XDMF                                   */
/*                       eXtensible Data Model and Format                    */
/*                                                                           */
/*  Id : XdmfGraph.hpp                                                       */
/*                                                                           */
/*  Author:                                                                  */
/*     Kenneth Leiter                                                        */
/*     kenneth.leiter@arl.army.mil                                           */
/*     US Army Research Laboratory                                           */
/*     Aberdeen Proving Ground, MD                                           */
/*                                                                           */
/*     Copyright @ 2011 US Army Research Laboratory                          */
/*     All Rights Reserved                                                   */
/*     See Copyright.txt for details                                         */
/*                                                                           */
/*     This software is distributed WITHOUT ANY WARRANTY; without            */
/*     even the implied warranty of MERCHANTABILITY or FITNESS               */
/*     FOR A PARTICULAR PURPOSE.  See the above copyright notice             */
/*     for more information.                                                 */
/*                                                                           */
/*****************************************************************************/

#ifndef XDMFGRAPH_HPP_
#define XDMFGRAPH_HPP_

27
// C Compatible Includes
28
#include "Xdmf.hpp"
29
#include "XdmfAttribute.hpp"
Andrew J. Burns (Cont's avatar
Andrew J. Burns (Cont committed
30
#include "XdmfTime.hpp"
31 32
#include "XdmfSparseMatrix.hpp"

33 34
#ifdef __cplusplus

35 36 37 38 39 40 41 42 43 44 45 46 47
/**
 * @brief Graph stored in sparse matrix form.
 *
 * Stores graph information in sparse matrix form. Attributes defining
 * node and edge information can be inserted.
 */
class XDMF_EXPORT XdmfGraph : public XdmfSparseMatrix {

public:

  /**
   * Create a new XdmfGraph.
   *
48 49 50 51 52
   * Example of use:
   *
   * C++
   *
   * @dontinclude ExampleXdmfGraph.cpp
53 54
   * @skipline //#initialization
   * @until //#initialization
55 56 57 58
   *
   * Python
   *
   * @dontinclude XdmfExampleGraph.py
59 60
   * @skipline #//initialization
   * @until #//initialization
61
   *
62 63
   * @param numberNodes number of nodes in graph.
   *
64
   * @return    Constructed XdmfGraph.
65 66 67 68 69
   */
  static shared_ptr<XdmfGraph> New(const unsigned int numberNodes);

  virtual ~XdmfGraph();

70 71
  LOKI_DEFINE_VISITABLE(XdmfGraph, XdmfSparseMatrix)
  XDMF_CHILDREN(XdmfGraph, XdmfAttribute, Attribute, Name)
72 73 74 75
  static const std::string ItemTag;

  std::string getItemTag() const;

76 77 78 79
  shared_ptr<XdmfTime> getTime();

  shared_ptr<const XdmfTime> getTime() const;

80 81
  unsigned int getNumberNodes() const;

82 83
  using XdmfSparseMatrix::insert;

84 85
  void setTime(const shared_ptr<XdmfTime> time);

86 87
  void traverse(const shared_ptr<XdmfBaseVisitor> visitor);

88 89
  XdmfGraph(XdmfGraph &);

90 91 92 93 94 95 96 97 98 99 100 101 102
protected:

  XdmfGraph(const unsigned int numberNodes);

  virtual void
  populateItem(const std::map<std::string, std::string> & itemProperties,
               const std::vector<shared_ptr<XdmfItem> > & childItems,
               const XdmfCoreReader * const reader);

private:

  XdmfGraph(const XdmfGraph &);  // Not implemented.
  void operator=(const XdmfGraph &);  // Not implemented.
103 104

  shared_ptr<XdmfTime> mTime;
105 106
};

107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
#endif

#ifdef __cplusplus
extern "C" {
#endif

// C wrappers go here

struct XDMFGRAPH; // Simply as a typedef to ensure correct typing
typedef struct XDMFGRAPH XDMFGRAPH;

XDMF_EXPORT XDMFGRAPH * XdmfGraphNew(unsigned int numberNodes);

XDMF_EXPORT XDMFATTRIBUTE * XdmfGraphGetAttribute(XDMFGRAPH * graph, unsigned int index);

XDMF_EXPORT XDMFATTRIBUTE * XdmfGraphGetAttributeByName(XDMFGRAPH * graph, char * Name);

XDMF_EXPORT unsigned int XdmfGraphGetNumberAttributes(XDMFGRAPH * graph);

XDMF_EXPORT void XdmfGraphInsertAttribute(XDMFGRAPH * graph, XDMFATTRIBUTE * Attribute, int passControl);

XDMF_EXPORT void XdmfGraphRemoveAttribute(XDMFGRAPH * graph, unsigned int index);

XDMF_EXPORT void XdmfGraphRemoveAttributeByName(XDMFGRAPH * graph, char * Name);

XDMF_EXPORT unsigned int XdmfGraphGetNumberNodes(XDMFGRAPH * graph);

XDMF_ITEM_C_CHILD_DECLARE(XdmfGraph, XDMFGRAPH, XDMF)
XDMF_SPARSEMATRIX_C_CHILD_DECLARE(XdmfGraph, XDMFGRAPH, XDMF)

#ifdef __cplusplus
}
#endif

141
#endif /* XDMFGRAPH_HPP_ */