[Contact] Refactoring API structures
[profile/ivi/wrt-plugins-tizen.git] / src / platform / API / Contact / ContactPhoneNumber.cpp
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * @file        ContactPhoneNumber.cpp
19  * @author      Kisub Song (kisubs.song@samsung.com)
20  * @version     0.1
21  * @brief
22  */
23
24 #include "ContactPhoneNumber.h"
25
26 namespace TizenApis {
27 namespace Api {
28 namespace Contact {
29
30 using namespace std;
31
32 ContactPhoneNumber::ContactPhoneNumber() :
33                 m_numberIsSet(false)
34 {
35         m_types = ContactPhoneNumberTypeArrayPtr(new ContactPhoneNumberTypeArray());
36 }
37
38 ContactPhoneNumber::~ContactPhoneNumber()
39 {
40 }
41
42 std::string ContactPhoneNumber::getNumber() const
43 {
44         return m_number;
45 }
46
47 void ContactPhoneNumber::setNumber(const std::string &value)
48 {
49         m_number = value;
50         m_numberIsSet = true;
51 }
52
53 void ContactPhoneNumber::unsetNumber()
54 {
55         m_number = "";
56         m_numberIsSet = false;
57 }
58
59 bool ContactPhoneNumber::getNumberIsSet() const
60 {
61         return m_numberIsSet;
62 }
63
64 ContactPhoneNumberTypeArrayPtr ContactPhoneNumber::getTypes() const
65 {
66         return m_types;
67 }
68
69 void ContactPhoneNumber::setTypes(const ContactPhoneNumberTypeArrayPtr &value)
70 {
71         m_types = value;
72 }
73
74 void ContactPhoneNumber::addType(const ContactPhoneNumberType value)
75 {
76         m_types->push_back(value);
77 }
78
79 bool ContactPhoneNumber::isTypeOf(const ContactPhoneNumberType value) const
80 {
81         return std::find(m_types->begin(), m_types->end(), value) != m_types->end();
82 }
83
84 int ContactPhoneNumber::getTypesNum() const
85 {
86         return m_types->size();
87 }
88
89 void ContactPhoneNumber::clear()
90 {
91         m_number = "";
92         m_numberIsSet = false;
93
94         m_types = ContactPhoneNumberTypeArrayPtr(new ContactPhoneNumberTypeArray());
95 }
96
97 ContactPhoneNumberPtr ContactPhoneNumber::clone() const
98 {
99         ContactPhoneNumberPtr result(new ContactPhoneNumber());
100
101         result->m_number = m_number;
102         result->m_numberIsSet = m_numberIsSet;
103
104         result->m_types = ContactPhoneNumberTypeArrayPtr(new ContactPhoneNumberTypeArray());
105         ContactPhoneNumberTypeArray::iterator typeIter;
106         for(typeIter = m_types->begin(); typeIter != m_types->end(); typeIter++)
107         {
108                 ContactPhoneNumberType type = *typeIter;
109                 result->m_types->push_back(type);
110         }
111
112         return result;
113 }
114
115 } // Contact
116 } // Api
117 } // TizenApis