Bidi implementation
[platform/core/uifw/dali-adaptor.git] / text / dali / internal / text-abstraction / bidirectional-support-impl.h
1 #ifndef __DALI_INTERNAL_TEXT_ABSTRACTION_BIDIRECTIONAL_SUPPORT_IMPL_H__
2 #define __DALI_INTERNAL_TEXT_ABSTRACTION_BIDIRECTIONAL_SUPPORT_IMPL_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/base-object.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/text-abstraction/bidirectional-support.h>
26
27 namespace Dali
28 {
29
30 namespace TextAbstraction
31 {
32
33 namespace Internal
34 {
35
36 /**
37  * Implementation of the BidirectionalSupport
38  */
39 class BidirectionalSupport : public Dali::BaseObject
40 {
41 public:
42
43   /**
44    * Constructor
45    */
46   BidirectionalSupport();
47
48   /**
49    * Destructor
50    */
51   ~BidirectionalSupport();
52
53   /**
54    * @copydoc Dali::BidirectionalSupport::Get()
55    */
56   static TextAbstraction::BidirectionalSupport Get();
57
58   /**
59    * @copydoc Dali::BidirectionalSupport::CreateInfo()
60    */
61   BidiInfoIndex CreateInfo( const Character* const paragraph,
62                             Length numberOfCharacters );
63
64   /**
65    * @copydoc Dali::BidirectionalSupport::DestroyInfo()
66    */
67   void DestroyInfo( BidiInfoIndex bidiInfoIndex );
68
69   /**
70    * @copydoc Dali::BidirectionalSupport::Reorder()
71    */
72   void Reorder( BidiInfoIndex bidiInfoIndex,
73                 CharacterIndex firstCharacterIndex,
74                 Length numberOfCharacters,
75                 CharacterIndex* visualToLogicalMap );
76
77 private:
78
79   // Undefined copy constructor.
80   BidirectionalSupport( const BidirectionalSupport& );
81
82   // Undefined assignment constructor.
83   BidirectionalSupport& operator=( BidirectionalSupport& );
84
85   void* mPlugin; ///< TODO replace this with bidirectional support plugin
86
87 private:
88
89   /**
90    * Stores bidirectional info per paragraph.
91    */
92   struct BidirectionalInfo;
93
94   Vector<BidirectionalInfo*> mParagraphBidirectionalInfo; ///< Stores the bidirectional info per paragraph.
95   Vector<BidiInfoIndex>      mFreeIndices;                ///< Stores indices of free positions in the bidirectional info vector.
96
97 }; // class BidirectionalSupport
98
99 } // namespace Internal
100
101 } // namespace TextAbstraction
102
103 inline static TextAbstraction::Internal::BidirectionalSupport& GetImplementation( TextAbstraction::BidirectionalSupport& bidirectionalSupport )
104 {
105   DALI_ASSERT_ALWAYS( bidirectionalSupport && "bidirectional support handle is empty" );
106   BaseObject& handle = bidirectionalSupport.GetBaseObject();
107   return static_cast<TextAbstraction::Internal::BidirectionalSupport&>(handle);
108 }
109
110 inline static const TextAbstraction::Internal::BidirectionalSupport& GetImplementation( const TextAbstraction::BidirectionalSupport& bidirectionalSupport )
111 {
112   DALI_ASSERT_ALWAYS( bidirectionalSupport && "bidirectional support handle is empty" );
113   const BaseObject& handle = bidirectionalSupport.GetBaseObject();
114   return static_cast<const TextAbstraction::Internal::BidirectionalSupport&>(handle);
115 }
116
117 } // namespace Dali
118
119 #endif // __DALI_INTERNAL_TEXT_ABSTRACTION_BIDIRECTIONAL_SUPPORT_IMPL_H__