3D Repo Bouncer  1.4
repo_node_reference.h
1 
21 #pragma once
22 #include "repo_node.h"
23 
24 //------------------------------------------------------------------------------
25 //
26 // Fields specific to reference only
27 //
28 //------------------------------------------------------------------------------
29 #define REPO_NODE_REFERENCE_LABEL_REVISION_ID "_rid"
30 #define REPO_NODE_REFERENCE_LABEL_UNIQUE "unique"
31 #define REPO_NODE_REFERENCE_LABEL_PROJECT "project"
32 #define REPO_NODE_REFERENCE_LABEL_OWNER "owner"
33 //------------------------------------------------------------------------------
34 
35 namespace repo {
36  namespace core {
37  namespace model {
38  class REPO_API_EXPORT ReferenceNode :public RepoNode
39  {
40  public:
41 
45  ReferenceNode();
46 
51  ReferenceNode(RepoBSON bson);
52 
56  ~ReferenceNode();
57 
62  virtual std::string getType() const
63  {
64  return REPO_NODE_TYPE_REFERENCE;
65  }
66 
71  virtual NodeType getTypeAsEnum() const
72  {
73  return NodeType::REFERENCE;
74  }
75 
83  virtual bool sEqual(const RepoNode &other) const;
84 
85  /*
86  * ------------- Convenience getters --------------
87  */
88 
94  repoUUID getRevisionID() const{
95  if (hasField(REPO_NODE_REFERENCE_LABEL_REVISION_ID))
96  return getUUIDField(REPO_NODE_REFERENCE_LABEL_REVISION_ID);
97  else
98  return stringToUUID(REPO_HISTORY_MASTER_BRANCH);
99  }
100 
105  std::string getDatabaseName() const{
106  return getStringField(REPO_NODE_REFERENCE_LABEL_OWNER);
107  }
108 
113  std::string getProjectName() const{
114  return getStringField(REPO_NODE_REFERENCE_LABEL_PROJECT);
115  }
116 
123  bool useSpecificRevision() const
124  {
125  bool isUnique = false; //defaults to false.
126  if (hasField(REPO_NODE_REFERENCE_LABEL_UNIQUE))
127  isUnique = getField(REPO_NODE_REFERENCE_LABEL_UNIQUE).boolean();
128 
129  return isUnique;
130  }
131  };
132  } //namespace model
133  } //namespace core
134 } //namespace repo
Definition: repo_node_reference.h:38
Definition: repo_connection_pool_mongo.h:32
repoUUID getRevisionID() const
Definition: repo_node_reference.h:94
virtual std::string getType() const
Definition: repo_node_reference.h:62
std::string getDatabaseName() const
Definition: repo_node_reference.h:105
std::string getProjectName() const
Definition: repo_node_reference.h:113
Definition: repo_node.h:33
virtual NodeType getTypeAsEnum() const
Definition: repo_node_reference.h:71
Definition: repo_bson.h:53
bool useSpecificRevision() const
Definition: repo_node_reference.h:123