Home | History | Annotate | Download | only in hidl
      1 /*
      2  * Copyright (C) 2016 The Android Open Source Project
      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 #ifndef NAMED_TYPE_H_
     18 
     19 #define NAMED_TYPE_H_
     20 
     21 #include "Location.h"
     22 #include "Type.h"
     23 
     24 #include <hidl-util/FQName.h>
     25 
     26 #include <string>
     27 
     28 namespace android {
     29 
     30 struct Scope;
     31 
     32 struct NamedType : public Type {
     33     NamedType(const char* localName, const Location& loc, Scope* parent);
     34 
     35     bool isNamedType() const override;
     36 
     37     void setFullName(const FQName &fullName);
     38 
     39     const FQName &fqName() const;
     40 
     41     std::string localName() const;
     42 
     43     /* short for fqName().cppName() */
     44     std::string fullName() const;
     45     /* short for fqName().cppLocalName() */
     46     std::string partialCppName() const;
     47     /* short for fqName().fullJavaName() */
     48     std::string fullJavaName() const;
     49 
     50     // returns null if no location is set for this type.
     51     const Location &location() const;
     52 
     53     void emitDump(
     54             Formatter &out,
     55             const std::string &streamName,
     56             const std::string &name) const override;
     57 
     58     Scope* parent() const;
     59 
     60    private:
     61     std::string mLocalName;
     62     FQName mFullName;
     63     Location mLocation;
     64     Scope* const mParent;
     65 
     66     DISALLOW_COPY_AND_ASSIGN(NamedType);
     67 };
     68 
     69 }  // namespace android
     70 
     71 #endif  // NAMED_TYPE_H_
     72 
     73