1 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
2 // Copyright (c) Lawrence Livermore National Security, LLC and other Ascent
3 // Project developers. See top-level LICENSE AND COPYRIGHT files for dates and
4 // other details. No copyright assignment is required to contribute to Ascent.
5 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
6 
7 
8 //-----------------------------------------------------------------------------
9 ///
10 /// file: ascent_runtime_utils.cpp
11 ///
12 //-----------------------------------------------------------------------------
13 
14 #include "ascent_runtime_utils.hpp"
15 #include <ascent_logging.hpp>
16 #include <ascent_string_utils.hpp>
17 #include <ascent_metadata.hpp>
18 
19 #include <algorithm>
20 
21 using namespace conduit;
22 
23 //-----------------------------------------------------------------------------
24 // -- begin ascent:: --
25 //-----------------------------------------------------------------------------
26 namespace ascent
27 {
28 
29 //-----------------------------------------------------------------------------
30 // -- begin ascent::runtime --
31 //-----------------------------------------------------------------------------
32 namespace runtime
33 {
34 
35 //-----------------------------------------------------------------------------
36 // -- begin ascent::runtime::filters --
37 //-----------------------------------------------------------------------------
38 namespace filters
39 {
40 
output_dir(const std::string file_name)41 std::string output_dir(const std::string file_name)
42 {
43   std::string output_path;
44 
45   std::string file, base_path;
46   conduit::utils::rsplit_file_path(file_name, file, base_path);
47   if(base_path == "")
48   {
49     std::string dir = default_dir();
50     output_path = conduit::utils::join_file_path(dir, file);
51   }
52   else
53   {
54     output_path = file_name;
55   }
56   return output_path;
57 }
58 
default_dir()59 std::string default_dir()
60 {
61   if(Metadata::n_metadata.has_path("default_dir"))
62   {
63     return Metadata::n_metadata["default_dir"].as_string();
64   }
65   else return ".";
66 }
67 
filter_to_path(const std::string filter_name)68 std::string filter_to_path(const std::string filter_name)
69 {
70   std::string res;
71   std::vector<std::string> path = split(filter_name, '_');
72   for(size_t i = 0; i < path.size(); ++i)
73   {
74     res += path[i];
75     if(i != path.size() - 1)
76     {
77       res += "/";
78     }
79   }
80   return res;
81 }
82 //-----------------------------------------------------------------------------
83 };
84 //-----------------------------------------------------------------------------
85 // -- end ascent::runtime::filters --
86 //-----------------------------------------------------------------------------
87 
88 
89 //-----------------------------------------------------------------------------
90 };
91 //-----------------------------------------------------------------------------
92 // -- end ascent::runtime --
93 //-----------------------------------------------------------------------------
94 
95 
96 //-----------------------------------------------------------------------------
97 };
98 //-----------------------------------------------------------------------------
99 // -- end ascent:: --
100 //-----------------------------------------------------------------------------
101 
102 
103 
104 
105 
106