merge the reviewed files
[framework/osp/nfc.git] / inc / FNetNfcNdefRecord.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18  * @file    FNetNfcNdefRecord.h
19  * @brief   This is the header file for the %NdefRecord class.
20  *
21  * This header file contains the declarations of the %NdefRecord class.
22  */
23
24 #ifndef _FNET_NFC_NDEF_RECORD_H_
25 #define _FNET_NFC_NDEF_RECORD_H_
26
27 #include <FBaseObject.h>
28 #include <FBaseResult.h>
29
30 namespace Tizen { namespace Base
31 {
32 class ByteBuffer;
33 class String;
34 } }
35
36 namespace Tizen { namespace Net { namespace Nfc
37 {
38
39 class _NdefRecordImpl;
40 class NdefMessage;
41 class NdefRecordType;
42
43 /**
44  * @class   NdefRecord
45  * @brief   This class represents an NDEF record.
46  *
47  * @since   2.0
48  *
49  * The %NdefRecord class represents an NDEF record, including certain attributes such as the type, the payload, and the
50  * payload identifier. It provides the operations to manipulate them. However, this class does not expose all the
51  * attributes of an NDEF record. Some attributes defined in the NDEF specification are hidden because they are not
52  * important for applications. @n
53  * The NDEF record may contain an NDEF message in the payload. It can be converted from a Tizen::Base::ByteBuffer 
54  * instance to an NdefMessage instance through the NdefMessage::GetInstanceN() method.
55  *
56  * For more information on the class features, see
57  * <a href="../org.tizen.native.appprogramming/html/guide/net/nfc.htm">NFC Guide</a>.
58  */
59 class _OSP_EXPORT_ NdefRecord
60         : public Tizen::Base::Object
61 {
62 public:
63         /**
64          * Initializes this instance of %NdefRecord with the specified parameter.
65          *
66          * @since       2.0
67          *
68          * @param[in]   recordType      A specified NDEF record type
69          */
70         NdefRecord(const NdefRecordType& recordType);
71
72         /**
73          * Copying of objects using this copy constructor is allowed.
74          *
75          * @since       2.0
76          *
77          * @param[in]   value           An instance of %NdefRecord
78          * @remarks     It performs a deep copy.
79          */
80         NdefRecord(const NdefRecord& value);
81
82         /**
83          * This destructor overrides Tizen::Base::Object::~Object().
84          *
85          * @since       2.0
86          */
87         virtual ~NdefRecord(void);
88
89         /**
90          * Compares the calling instance with the specified instance.
91          *
92          * @since       2.0
93          *
94          * @return      @c true if the specified instance of Tizen::Base::Object is equal to the calling %NdefRecord instance, @n
95          *              else @c false
96          * @param[in]   obj                    The object to compare
97          * @remark      Two %NdefRecord instances are equal only if they contain the same NdefRecordType instances,
98          *              payload ID, and payload.
99          */
100         virtual bool Equals(const Tizen::Base::Object& obj) const;
101
102         /**
103          * Gets the hash value of the current instance.
104          *
105          * @since       2.0
106          *
107          * @return      The hash value of the current instance
108          */
109         virtual int GetHashCode(void) const;
110
111         /**
112          * Gets the payload identifier for this NDEF record.
113          *
114          * @since       2.0
115          *
116          * @return      The identifier of the payload, @n
117          *              else an empty string if the identifier does not exist in the NDEF record
118          */
119         Tizen::Base::String GetPayloadId(void) const;
120
121         /**
122          * Gets the payload in this record as Tizen::Base::ByteBuffer.
123          *
124          * @since       2.0
125          *
126          * @return      The payload, @n
127          *              else @c null if the NDEF record does not have the payload
128          * @remarks     If the payload is modified after it is fetched, the payload of this record also changes.
129          */
130         Tizen::Base::ByteBuffer* GetPayload(void) const;
131
132         /**
133          * Gets the record type of the NDEF record.
134          *
135          * @since       2.0
136          *
137          * @return      The record type of the NDEF record
138          */
139         NdefRecordType GetRecordType(void) const;
140
141         /**
142          * Sets the record type of the NDEF record.
143          *
144          * @since       2.0
145          *
146          * @return      An error code
147          * @param[in]   type                The record type to set
148          * @exception   E_SUCCESS           The method is successful.
149          * @exception   E_INVALID_ARG       The input argument is invalid. @n
150          *                                  For example, @c NDEF_TNF_EMPTY is not allowed as the input value if the identifier
151          *                                  is not an empty string or the payload is not @c null.
152          */
153         result SetRecordType(NdefRecordType& type);
154
155         /**
156          * Sets the identifier of the payload.
157          *
158          * @since       2.0
159          *
160          * @return      An error code
161          * @param[in]   id                          The identifier of the payload
162          * @exception   E_SUCCESS                   The method is successful.
163          * @exception   E_INVALID_OPERATION         This operation is not allowed if the type name format of this record is
164          *                                          @c NDEF_TNF_EMPTY.
165          * @exception   E_INVALID_ARG               The specified identifier is not unique compared to the other records in
166          *                                          the same NDEF message.
167          * @exception   E_INVALID_ENCODING_RANGE    The specified input string contains code points that are outside the
168          *                                          bounds specified by the US_ASCII encoding scheme.
169          * @exception   E_MAX_EXCEEDED              The length of @c id exceeds @c 256 characters.
170          * @remarks     The identifier is compared with other records only if this NDEF record is already included in an
171          *              NDEF message.
172          */
173         result SetPayloadId(const Tizen::Base::String& id);
174
175         /**
176          * Sets the specified data in the payload of this NDEF record.
177          *
178          * @since       2.0
179          *
180          * @return      An error code
181          * @param[in]   payload                 The specified payload data
182          * @exception   E_SUCCESS               The method is successful.
183          * @exception   E_INVALID_OPERATION     This operation is not allowed if the type name format of this record is
184          *                                      @c NDEF_TNF_EMPTY.
185          * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
186          * @exception   E_INVALID_ARG           The @c payload is invalid. @n
187          *                                      For example, @c payload is not constructed.
188          * @remarks     The view of the specified @c payload parameter is copied and the data is shared. Therefore, if the
189          *              data of @c payload is modified after setting, the data of the payload in this record also changes.
190          */
191         result SetPayload(const Tizen::Base::ByteBuffer& payload);
192
193         /**
194          * Assigns the value of the specified instance to the current instance of %NdefRecord.
195          *
196          * @since       2.0
197          *
198          * @return      A reference to the %NdefRecord instance
199          * @param[in]   rhs                     A reference to the %NdefRecord instance to copy
200          */
201         NdefRecord& operator =(const NdefRecord& rhs);
202
203 private:
204         //
205         // This default constructor is intentionally declared as private so that only the platform can create an instance.
206         //
207         NdefRecord(void);
208
209 private:
210         _NdefRecordImpl* __pImpl;
211
212         friend class _NdefRecordImpl;
213
214 }; // NdefRecord
215
216 } } } // Tizen::Net::Nfc
217
218 #endif // _FNET_NFC_NDEF_RECORD_H_