1 /******************************************************************************
2 * Copyright (c) 2000-2016 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
12 ******************************************************************************/
13 #ifndef ATTRIBUTETYPE_HH_
14 #define ATTRIBUTETYPE_HH_
16 #include "SimpleType.hh"
17 #include "GeneralTypes.hh"
18 #include "GeneralFunctions.hh"
19 #include "GeneralFunctions.hh"
20 #include "TTCN3Module.hh"
21 #include "TTCN3ModuleInventory.hh"
22 #include "ComplexType.hh"
23 #include "Annotation.hh"
26 * Type that contains information of a field of a TTCN-3 record or union
29 class AttributeType : public SimpleType {
38 bool used; // To know if already in the extended or restricted type
40 TTCN3Module * origModule;
43 explicit AttributeType(ComplexType * a_complextype);
44 AttributeType(const AttributeType & other);
45 AttributeType & operator=(const AttributeType & rhs);
46 virtual ~AttributeType();
47 void setTypeOfField(const Mstring& in);
48 void setNameOfField(const Mstring& in);
50 void setOrigModule(TTCN3Module * m) {
54 const TTCN3Module * getOrigModule() const {
57 void setToAnyAttribute();
60 void setUseVal(UseValue use_value) {
63 void setFieldPath(const Mstring path);
64 void collectVariants(List<Mstring>& container);
66 UseValue getUseVal() const {
70 bool getUsed() const {
74 void setUsed(bool use) {
78 const Mstring& getNameSpaceAttribute() const {
82 void addNameSpaceAttribute(Mstring namespace_) {
83 if(nameSpace.empty()){
84 nameSpace = namespace_;
86 nameSpace += " " + namespace_;
89 void nameConversion_names(QualifiedNames& used);
90 void applyUseAttribute();
91 void applyNamespaceAttribute(VariantMode varLabel);
93 void applyMinMaxOccursAttribute(unsigned long long min, unsigned long long max);
95 const Mstring& getPath() const {
99 bool isAnyAttribute() const {
103 void printToFile(FILE* file) {
104 printToFile(file, 0);
106 void printToFile(FILE* file, unsigned level);
108 void dump(unsigned int depth) const;
112 inline bool compareAttributeNameSpaces(AttributeType * lhs, AttributeType * rhs) {
113 if (lhs->isAnyAttribute()) {
116 if (lhs->getOrigModule()->getTargetNamespace() == Mstring("NoTargetNamespace") && rhs->getOrigModule()->getTargetNamespace() == Mstring("NoTargetNamespace")) {
118 } else if (lhs->getOrigModule()->getTargetNamespace() == Mstring("NoTargetNamespace")) {
120 } else if (rhs->getOrigModule()->getTargetNamespace() == Mstring("NoTargetNamespace")) {
123 return lhs->getOrigModule()->getTargetNamespace() <= rhs->getOrigModule()->getTargetNamespace();
127 inline bool compareAttributeTypes(AttributeType * lhs, AttributeType * rhs) {
128 if (lhs->isAnyAttribute()) {
131 if (lhs->getOrigModule()->getTargetNamespace() == rhs->getOrigModule()->getTargetNamespace()) {
132 return lhs->getName().originalValueWoPrefix < rhs->getName().originalValueWoPrefix;
139 #endif /* ATTRIBUTETYPE_HH_ */