Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / tests / helpers / test_model_path.hpp
1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 #pragma once
6
7 #include <sstream>
8
9 static const char kPathSeparator =
10 #if defined _WIN32 || defined __CYGWIN__
11     '\\';
12 #else
13     '/';
14 #endif
15
16 class ModelsPath {
17     std::stringstream _rel_path;
18     mutable std::string _abs_path;
19
20  public:
21
22     ModelsPath() = default;
23
24     ModelsPath(const ModelsPath & that) {
25         _rel_path << that._rel_path.str();
26     }
27
28     template <class T>
29     ModelsPath operator + (const T & relative_path) const {
30         ModelsPath newPath(*this);
31         newPath += relative_path;
32         return newPath;
33     }
34
35     template <class T>
36     ModelsPath & operator += (const T & relative_path) {
37         _rel_path << relative_path;
38         return *this;
39     }
40
41     template <class T>
42     ModelsPath & operator << (const T & serializable) {
43         _rel_path << serializable;
44         return *this;
45     }
46
47     std::string str() const {
48         return this->operator std::string();
49     }
50
51     const char * c_str() const {
52         _abs_path = this->operator std::string ();
53         return _abs_path.c_str();
54     }
55
56     operator std::string() const;
57 };
58
59 inline std::ostream & operator << (std::ostream &os, const ModelsPath & path) {
60     os << path.str();
61     return os;
62 }