Home | History | Annotate | Download | only in dynamic_depth
      1 #include "dynamic_depth/const.h"
      2 
      3 #include "android-base/logging.h"
      4 #include "base/port.h"
      5 
      6 namespace dynamic_depth {
      7 namespace {
      8 
      9 // Element names.
     10 constexpr char kAppInfo[] = "AppInfo";
     11 constexpr char kCamera[] = "Camera";
     12 constexpr char kDepthMap[] = "DepthMap";
     13 constexpr char kDevice[] = "Device";
     14 constexpr char kEarthPose[] = "EarthPose";
     15 constexpr char kImagingModel[] = "ImagingModel";
     16 constexpr char kImage[] = "Image";
     17 constexpr char kItem[] = "Item";
     18 constexpr char kLightEstimate[] = "LightEstimate";
     19 constexpr char kPlane[] = "Plane";
     20 constexpr char kPointCloud[] = "PointCloud";
     21 constexpr char kPose[] = "Pose";
     22 constexpr char kProfile[] = "Profile";
     23 constexpr char kVendorInfo[] = "VendorInfo";
     24 
     25 // Type names.
     26 constexpr char kCameras[] = "Cameras";
     27 constexpr char kContainer[] = "Container";
     28 constexpr char kPlanes[] = "Planes";
     29 constexpr char kProfiles[] = "Profiles";
     30 
     31 }  // namespace
     32 
     33 // Redeclare static constexpr variables.
     34 // https://stackoverflow.com/questions/8016780/
     35 //     undefined-reference-to-static-constexpr-char
     36 constexpr std::array<const char*, DynamicDepthConst::kNumDistortionTypes>
     37     DynamicDepthConst::kDistortionTypeNames;
     38 
     39 // Dynamic Depth element names.
     40 const char* DynamicDepthConst::AppInfo() { return kAppInfo; }
     41 
     42 const char* DynamicDepthConst::Camera() { return kCamera; }
     43 
     44 const char* DynamicDepthConst::DepthMap() { return kDepthMap; }
     45 
     46 const char* DynamicDepthConst::Device() { return kDevice; }
     47 
     48 const char* DynamicDepthConst::EarthPose() { return kEarthPose; }
     49 
     50 const char* DynamicDepthConst::ImagingModel() { return kImagingModel; }
     51 
     52 const char* DynamicDepthConst::Image() { return kImage; }
     53 
     54 const char* DynamicDepthConst::Item() { return kItem; }
     55 
     56 const char* DynamicDepthConst::LightEstimate() { return kLightEstimate; }
     57 
     58 const char* DynamicDepthConst::Plane() { return kPlane; }
     59 
     60 const char* DynamicDepthConst::PointCloud() { return kPointCloud; }
     61 
     62 const char* DynamicDepthConst::Pose() { return kPose; }
     63 
     64 const char* DynamicDepthConst::Profile() { return kProfile; }
     65 
     66 const char* DynamicDepthConst::VendorInfo() { return kVendorInfo; }
     67 
     68 // Dynamic Depth type names.
     69 const char* DynamicDepthConst::Cameras() { return kCameras; }
     70 
     71 const char* DynamicDepthConst::Container() { return kContainer; }
     72 
     73 const char* DynamicDepthConst::Planes() { return kPlanes; }
     74 
     75 const char* DynamicDepthConst::Profiles() { return kProfiles; }
     76 
     77 // Returns the namespace to which the given Dynamic Depth element or type
     78 // belongs. AppInfo and VendorInfo are not included because they can belong to
     79 // either the Device or Camera elements.
     80 const std::string DynamicDepthConst::Namespace(const std::string& node_name) {
     81   if (node_name == kPose) {
     82     LOG(WARNING) << kPose << " maps to " << kDevice << ", " << kCamera
     83                  << ", and " << kPlane << "; should be manually chosen. "
     84                  << "Returning empty";
     85     return "";
     86   }
     87 
     88   // Elements.
     89   if (node_name == kImagingModel || node_name == kImage ||
     90       node_name == kDepthMap || node_name == kPointCloud ||
     91       node_name == kLightEstimate) {
     92     return kCamera;
     93   }
     94 
     95   if (node_name == kItem) {
     96     return kContainer;
     97   }
     98 
     99   if (node_name == kCamera || node_name == kEarthPose ||
    100       node_name == kProfile || node_name == kPlane) {
    101     return kDevice;
    102   }
    103 
    104   // Types.
    105   if (node_name == kCameras || node_name == kContainer ||
    106       node_name == kPlanes || node_name == kProfiles) {
    107     return kDevice;
    108   }
    109 
    110   return "";
    111 }
    112 }  // namespace dynamic_depth
    113