Coding idoms applied. isActive functional added.
[framework/osp/vision.git] / src / FUixVisionImageFeatureInfo.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 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 languae governing permissions and
15 // limitations under the License.
16 //
17
18 #include <FUixVisionImageFeatureInfo.h>
19 #include "FUixVision_ImageFeatureInfoImpl.h"
20 #include <FText.h>
21 #include <FBaseSysLog.h>
22
23 namespace Tizen { namespace Uix { namespace Vision
24 {
25
26 ImageFeatureInfo::ImageFeatureInfo()
27     : __pImageFeatureInfoImpl(0)
28 {
29     std::unique_ptr<_ImageFeatureInfoImpl> pImageFeatureInfoImpl (new (std::nothrow) _ImageFeatureInfoImpl());
30     __pImageFeatureInfoImpl = pImageFeatureInfoImpl.release();
31 }
32
33 ImageFeatureInfo::~ImageFeatureInfo()
34 {
35 }
36
37 Tizen::Base::String
38 ImageFeatureInfo::GetDescription() const
39 {
40     char ch;
41     int length = -1;
42
43     //get true length of path to allocate memory
44     length = __pImageFeatureInfoImpl->GetDescription(&ch, 1);
45     if (!length)
46     {
47         return Tizen::Base::String("");
48     }
49
50     char* pName = new char[length + 1];
51
52     //set data to char pointer, with allocated memory
53     __pImageFeatureInfoImpl->GetDescription(pName, length + 1);
54
55     Tizen::Base::String description(pName);
56     delete[] pName;
57     return description;
58 }
59
60 int
61 ImageFeatureInfo::GetThumbnailWidth(void) const
62 {
63     return __pImageFeatureInfoImpl->GetThumbnailWidth();
64 }
65
66 int
67 ImageFeatureInfo::GetThumbnailHeight(void) const
68 {
69     return __pImageFeatureInfoImpl->GetThumbnailHeight();
70 }
71
72 Tizen::Base::ByteBuffer*
73 ImageFeatureInfo::GetThumbnailN(void) const
74 {
75     int bufWidth  = __pImageFeatureInfoImpl->GetThumbnailWidth();
76     int bufHeight = __pImageFeatureInfoImpl->GetThumbnailHeight();
77
78     while ((bufWidth > 0) && (bufHeight > 0))
79     {
80         result res = E_FAILURE;
81         Tizen::Base::ByteBuffer* outBuffer = new Tizen::Base::ByteBuffer();
82         if (outBuffer == null)
83         {
84             break;
85         }
86         res = outBuffer->Construct(bufWidth * bufHeight);
87         if (IsFailed(res))
88         {
89             break;
90         }
91         if (__pImageFeatureInfoImpl->GetThumbnail((char*)outBuffer->GetPointer(), bufWidth, bufHeight, false))
92         {
93             return outBuffer;
94         }
95         break;
96     }
97     return null;
98 }
99
100 bool
101 ImageFeatureInfo::Equals(const Object& obj) const
102 {
103     return (static_cast<const Object*>(this) == &obj);
104 }
105
106 int
107 ImageFeatureInfo::GetHashCode(void) const
108 {
109     return (int)__pImageFeatureInfoImpl;
110 }
111
112 } } } //Tizen::Uix::Vision
113