/* * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef IDLC_TYPE_H_ #define IDLC_TYPE_H_ #include #include namespace tidl { class Token { public: Token(std::string name, std::string comments); virtual ~Token() = default; virtual std::string ToString() const { return name_; } virtual std::string GetComments() const { return comments_; } private: std::string name_; std::string comments_; }; class BaseType : public Token { public: explicit BaseType(std::string name, std::string comments, bool user_defined = false); BaseType(const BaseType& type); void SetMetaType(BaseType* type); const BaseType* GetMetaType() const { return meta_type_.get(); } std::string GetFullName() const { std::string str = ToString(); if (meta_type_.get() != nullptr) { str += "<"; str += meta_type_->GetFullName(); str += ">"; } return str; } bool IsUserDefinedType() const { return user_defined_; } private: std::unique_ptr meta_type_; bool user_defined_; }; class ParameterType { public: enum class Direction { IN, OUT, REF }; ParameterType(BaseType* type, const std::string& dir); explicit ParameterType(BaseType* type); Direction GetDirection() const { return dir_; } const BaseType& GetBaseType() const { return *type_; } private: std::unique_ptr type_; Direction dir_; }; } // namespace tidl #endif // IDLC_TYPE_H_