xref: /trunk/main/autodoc/source/ary/cpp/ca_type.cxx (revision d291ea28)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  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,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #include <precomp.h>
23 #include "ca_type.hxx"
24 
25 
26 // NOT FULLY DEFINED SERVICES
27 #include <ary/cpp/c_builtintype.hxx>
28 #include <ary/cpp/c_class.hxx>
29 #include <ary/cpp/c_namesp.hxx>
30 #include <ary/cpp/cp_ce.hxx>
31 #include <ary/cpp/inpcontx.hxx>
32 #include <ary/cpp/usedtype.hxx>
33 #include <ary/getncast.hxx>
34 #include "c_reposypart.hxx"
35 #include "cs_type.hxx"
36 
37 
38 
39 
40 namespace ary
41 {
42 namespace cpp
43 {
44 
45 
TypeAdmin(RepositoryPartition & io_myReposyPartition)46 TypeAdmin::TypeAdmin(RepositoryPartition & io_myReposyPartition)
47     :   aStorage(),
48         pCppRepositoryPartition(&io_myReposyPartition)
49 {
50 }
51 
~TypeAdmin()52 TypeAdmin::~TypeAdmin()
53 {
54 }
55 
56 
57 // KORR_FUTURE
58 //  Remove unused parameter.
59 
60 const Type &
CheckIn_UsedType(const InputContext &,DYN UsedType & pass_type)61 TypeAdmin::CheckIn_UsedType( const InputContext &   ,
62                              DYN UsedType &    	    pass_type )
63 {
64     Dyn<UsedType>
65         pNewType(&pass_type);  // Ensure clean up of heap object.
66 
67     Type_id
68         tid(0);
69     if (pass_type.IsBuiltInType())
70     {
71         tid = aStorage.Search_BuiltInType(
72                         BuiltInType::SpecializedName_( pass_type.LocalName().c_str(),
73                                                        pass_type.TypeSpecialisation() ));
74         csv_assert(tid.IsValid());
75         return aStorage[tid];
76     }
77 
78     tid = aStorage.UsedTypeIndex().Search(pass_type);
79     if (tid.IsValid())
80     {
81         return aStorage[tid];
82     }
83 
84     // Type does not yet exist:
85         // Transfer ownership from pNewTypeand assign id:
86 	aStorage.Store_Entity(*pNewType.Release());
87 
88     aStorage.UsedTypeIndex().Add(pass_type.TypeId());
89 	return pass_type;
90 }
91 
92 const Type &
Find_Type(Type_id i_type) const93 TypeAdmin::Find_Type(Type_id i_type) const
94 {
95     return aStorage[i_type];
96 }
97 
98 bool
Get_TypeText(StreamStr & o_result,Type_id i_type) const99 TypeAdmin::Get_TypeText( StreamStr &         o_result,
100                          Type_id             i_type ) const
101 {
102     if (NOT i_type.IsValid())
103         return false;
104     aStorage[i_type].Get_Text(o_result, *pCppRepositoryPartition);
105     return true;
106 }
107 
108 bool
Get_TypeText(StreamStr & o_preName,StreamStr & o_name,StreamStr & o_postName,Type_id i_type) const109 TypeAdmin::Get_TypeText( StreamStr &         o_preName,
110                          StreamStr &         o_name,
111                          StreamStr &         o_postName,
112                          Type_id             i_type ) const
113 {
114     if (NOT i_type.IsValid())
115         return false;
116     aStorage[i_type].Get_Text(o_preName, o_name, o_postName, *pCppRepositoryPartition);
117     return true;
118 }
119 
120 Type_id
Tid_Ellipse() const121 TypeAdmin::Tid_Ellipse() const
122 {
123     return Type_id(predefined::t_ellipse);
124 }
125 
126 
127 
128 
129 }   // namespace cpp
130 }   // namespace ary
131