nodeid.h
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 #pragma once
00012 
00013 #include <opc/ua/protocol/message_identifiers.h>
00014 #include <opc/ua/protocol/object_ids.h>
00015 #include <opc/ua/protocol/expanded_object_ids.h>
00016 #include <opc/ua/protocol/guid.h>
00017 #include <opc/ua/protocol/reference_ids.h>
00018 
00019 #include <sstream>
00020 #include <stdint.h>
00021 #include <string>
00022 #include <vector>
00023 
00024 namespace OpcUa
00025 {
00026 
00027   enum NodeIdEncoding : uint8_t
00028   {
00029     EV_TWO_BYTE = 0,
00030     EV_FOUR_BYTE = 1,
00031     EV_NUMERIC = 2,
00032     EV_STRING = 3,
00033     EV_GUId = 4,
00034     EV_BYTE_STRING = 5,
00035 
00036     EV_Server_INDEX_FLAG = 0x40,
00037     EV_NAMESPACE_URI_FLAG = 0x80,
00038 
00039     EV_VALUE_MASK = 0x3f,
00040   };
00041 
00042   struct ExpandedNodeId;
00043 
00044   struct NodeId
00045   {
00046     NodeIdEncoding Encoding;
00047     std::string NamespaceURI;
00048     uint32_t ServerIndex;
00049 
00050     struct TwoByteDataType
00051     {
00052       uint8_t Identifier;
00053 
00054       TwoByteDataType()
00055         : Identifier(0)
00056       {
00057       }
00058 
00059     } TwoByteData;
00060 
00061     struct FourByteDataType
00062     {
00063       uint8_t NamespaceIndex;
00064       uint16_t Identifier;
00065 
00066       FourByteDataType()
00067         : NamespaceIndex(0)
00068         , Identifier(0)
00069       {
00070       }
00071     }FourByteData;
00072 
00073     struct NumericDataType
00074     {
00075       uint16_t NamespaceIndex;
00076       uint32_t Identifier;
00077 
00078       NumericDataType()
00079         : NamespaceIndex(0)
00080         , Identifier(0)
00081       {
00082       }
00083     }NumericData;
00084 
00085 
00086     struct StringDataType
00087     {
00088       uint16_t NamespaceIndex;
00089       std::string Identifier;
00090 
00091       StringDataType()
00092         : NamespaceIndex(0)
00093       {
00094       }
00095 
00096     }StringData;
00097 
00098     struct BinaryDataType
00099     {
00100       uint16_t NamespaceIndex;
00101       std::vector<uint8_t> Identifier;
00102 
00103       BinaryDataType()
00104         : NamespaceIndex(0)
00105       {
00106       }
00107 
00108     }BinaryData;
00109 
00110     struct GuidDataType
00111     {
00112       uint16_t NamespaceIndex;
00113       Guid Identifier;
00114 
00115       GuidDataType()
00116         : NamespaceIndex(0)
00117       {
00118       }
00119 
00120     }GuidData;
00121 
00122     NodeId();
00123     NodeId(const NodeId& node);
00124     NodeId(const ExpandedNodeId& node);
00125     NodeId(MessageId messageId);
00126     NodeId(ReferenceId referenceId);
00127     NodeId(ObjectId objectId);
00128     NodeId(ExpandedObjectId objectId);
00129     NodeId(uint32_t integerId, uint16_t index);
00130     NodeId(std::string stringId, uint16_t index);
00131 
00132     NodeId& operator= (const NodeId& node);
00133     NodeId& operator= (const ExpandedNodeId& node);
00134 
00135     explicit operator ExpandedNodeId();
00136 
00137     NodeId& operator= (MessageId messageId)
00138     {
00139       *this = NodeId(messageId);
00140       return *this;
00141     }
00142 
00143     NodeId& operator= (ReferenceId referenceId)
00144     {
00145       *this = NodeId(referenceId);
00146       return *this;
00147     }
00148 
00149     NodeId& operator= (ObjectId objectId)
00150     {
00151       *this = NodeId(objectId);
00152       return *this;
00153     }
00154 
00155     NodeId& operator= (ExpandedObjectId objectId)
00156     {
00157       *this = NodeId(objectId);
00158       return *this;
00159     }
00160 
00161     bool operator== (const NodeId& node) const;
00162     bool operator== (MessageId messageId) const;
00163     bool operator== (ReferenceId referenceId) const;
00164     bool operator== (ObjectId objectId) const;
00165     bool operator== (ExpandedObjectId objectId) const;
00166 
00167     bool operator!= (const NodeId& node) const;
00168     bool operator!= (MessageId messageId) const;
00169     bool operator!= (ReferenceId referenceId) const;
00170     bool operator!= (ObjectId objectId) const;
00171     bool operator!= (ExpandedObjectId objectId) const;
00172 
00173     bool operator< (const NodeId& node) const;
00174 
00175     NodeIdEncoding GetEncodingValue() const;
00176     bool IsNull() const;
00177     bool HasNullIdentifier() const;
00178     bool HasNamespaceURI() const;
00179     bool HasServerIndex() const;
00180 
00181     void SetNamespaceURI(const std::string& uri);
00182     void SetServerIndex(uint32_t index);
00183     void SetNamespaceIndex(uint32_t ns);
00184 
00185     bool IsInteger() const;
00186     bool IsString() const;
00187     bool IsBinary() const;
00188     bool IsGuid() const;
00189 
00190     uint32_t GetNamespaceIndex() const;
00191 
00192     uint32_t GetIntegerIdentifier() const;
00193     std::string GetStringIdentifier() const;
00194     std::vector<uint8_t> GetBinaryIdentifier() const;
00195     Guid GetGuidIdentifier() const;
00196 
00197     protected:
00198     void CopyNodeId(const NodeId& node);
00199   };
00200 
00201   inline NodeId TwoByteNodeId(uint8_t value)
00202   {
00203     NodeId id;
00204     id.Encoding = EV_TWO_BYTE;
00205     id.TwoByteData.Identifier = value;
00206     return id;
00207   }
00208 
00209   inline NodeId FourByteNodeId(uint16_t value, uint8_t namespaceIndex = 0)
00210   {
00211     NodeId id;
00212     id.Encoding = EV_FOUR_BYTE;
00213     id.FourByteData.Identifier = value;
00214     id.FourByteData.NamespaceIndex = namespaceIndex;
00215     return id;
00216   }
00217 
00218   inline NodeId NumericNodeId(uint32_t value, uint16_t namespaceIndex = 0)
00219   {
00220     NodeId id;
00221     id.Encoding = EV_NUMERIC;
00222     id.NumericData.Identifier = value;
00223     id.NumericData.NamespaceIndex = namespaceIndex;
00224     return id;
00225   }
00226 
00227   inline NodeId StringNodeId(std::string value, uint16_t namespaceIndex = 0)
00228   {
00229     NodeId id;
00230     id.Encoding = EV_STRING;
00231     id.StringData.Identifier = value;
00232     id.StringData.NamespaceIndex = namespaceIndex;
00233     return id;
00234   }
00235 
00236   inline NodeId BinaryNodeId(std::vector<uint8_t> value, uint16_t namespaceIndex = 0)
00237   {
00238     NodeId id;
00239     id.Encoding = EV_BYTE_STRING;
00240     id.BinaryData.Identifier = value;
00241     id.BinaryData.NamespaceIndex = namespaceIndex;
00242     return id;
00243   }
00244 
00245   inline NodeId GuidNodeId(Guid value, uint16_t namespaceIndex = 0)
00246   {
00247     NodeId id;
00248     id.Encoding = EV_GUId;
00249     id.GuidData.Identifier = value;
00250     id.GuidData.NamespaceIndex = namespaceIndex;
00251     return id;
00252   }
00253 
00254   struct ExpandedNodeId : public NodeId
00255   {
00256     ExpandedNodeId();
00257     ExpandedNodeId(const NodeId& node);
00258     ExpandedNodeId(const ExpandedNodeId& node);
00259     ExpandedNodeId(MessageId messageId);
00260     ExpandedNodeId(ReferenceId referenceId);
00261     ExpandedNodeId(ObjectId objectId);
00262     ExpandedNodeId(ExpandedObjectId objectId);
00263     ExpandedNodeId(uint32_t integerId, uint16_t index);
00264     ExpandedNodeId(std::string stringId, uint16_t index);
00265 
00266    //using NodeId::NodeId;
00267    //using base::base;
00268   };
00269 
00270 } // namespace OpcUa
00271 
00272 


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Sat Jun 8 2019 18:24:56