LSST Applications g0da5cf3356+25b44625d0,g17e5ecfddb+50a5ac4092,g1c76d35bf8+585f0f68a2,g295839609d+8ef6456700,g2e2c1a68ba+cc1f6f037e,g38293774b4+62d12e78cb,g3b44f30a73+2891c76795,g48ccf36440+885b902d19,g4b2f1765b6+0c565e8f25,g5320a0a9f6+bd4bf1dc76,g56364267ca+403c24672b,g56b687f8c9+585f0f68a2,g5c4744a4d9+78cd207961,g5ffd174ac0+bd4bf1dc76,g6075d09f38+3075de592a,g667d525e37+cacede5508,g6f3e93b5a3+da81c812ee,g71f27ac40c+cacede5508,g7212e027e3+eb621d73aa,g774830318a+18d2b9fa6c,g7985c39107+62d12e78cb,g79ca90bc5c+fa2cc03294,g881bdbfe6c+cacede5508,g91fc1fa0cf+82a115f028,g961520b1fb+2534687f64,g96f01af41f+f2060f23b6,g9ca82378b8+cacede5508,g9d27549199+78cd207961,gb065e2a02a+ad48cbcda4,gb1df4690d6+585f0f68a2,gb35d6563ee+62d12e78cb,gbc3249ced9+bd4bf1dc76,gbec6a3398f+bd4bf1dc76,gd01420fc67+bd4bf1dc76,gd59336e7c4+c7bb92e648,gf46e8334de+81c9a61069,gfed783d017+bd4bf1dc76,v25.0.1.rc3
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
lsst::daf::persistence::LogicalLocation Class Reference

Class for logical location of a persisted Persistable instance. More...

#include <LogicalLocation.h>

Public Types

typedef std::shared_ptr< LogicalLocationPtr
 

Public Member Functions

 LogicalLocation (std::string const &locString, std::shared_ptr< dafBase::PropertySet const > additionalData=std::shared_ptr< dafBase::PropertySet const >())
 Constructor from string and additional data. More...
 
std::string const & locString (void) const
 Accessor. More...
 

Static Public Member Functions

static void setLocationMap (std::shared_ptr< dafBase::PropertySet > map)
 Set the logical-to-less-logical map. More...
 

Detailed Description

Class for logical location of a persisted Persistable instance.

Implemented as a minimal string representing a pathname or a database connection string. Interpreted by FormatterStorage subclasses.

Definition at line 59 of file LogicalLocation.h.

Member Typedef Documentation

◆ Ptr

Definition at line 61 of file LogicalLocation.h.

Constructor & Destructor Documentation

◆ LogicalLocation()

lsst::daf::persistence::LogicalLocation::LogicalLocation ( std::string const &  locString,
std::shared_ptr< dafBase::PropertySet const >  additionalData = std::shared_ptr<dafBase::PropertySet const>() 
)

Constructor from string and additional data.

Definition at line 62 of file LogicalLocation.cc.

64 : _locString() {
65 std::regex expr("(%.*?)\\((\\w+?)\\)");
68 LOGLS_DEBUG(_log, "Input string: " << locString);
69 while (i != std::sregex_iterator()) {
70 last = i;
71 if ((*i).prefix().matched) {
72 _locString += (*i).prefix().str();
73 }
74 std::string fmt = (*i).str(1);
75 std::string key = (*i).str(2);
76 LOGLS_DEBUG(_log, "Key: " << key);
77 if (_map && _map->exists(key)) {
78 if (_map->typeOf(key) == typeid(int)) {
79 int value = _map->getAsInt(key);
80 LOGLS_DEBUG(_log, "Map Val: " << value);
81 if (fmt == "%") {
82 _locString += (boost::format("%1%") % value).str();
83 } else {
84 _locString += (boost::format(fmt) % value).str();
85 }
86 } else {
87 std::string value = _map->getAsString(key);
88 LOGLS_DEBUG(_log, "Map Val: " << value);
89 _locString += value;
90 }
91 } else if (additionalData && additionalData->exists(key)) {
92 if (additionalData->typeOf(key) == typeid(int)) {
93 int value = additionalData->getAsInt(key);
94 LOGLS_DEBUG(_log, "Map Val: " << value);
95 if (fmt == "%") {
96 _locString += (boost::format("%1%") % value).str();
97 } else {
98 _locString += (boost::format(fmt) % value).str();
99 }
100 } else {
101 std::string value = additionalData->getAsString(key);
102 LOGLS_DEBUG(_log, "Map Val: " << value);
103 _locString += value;
104 }
105 } else {
106 throw LSST_EXCEPT(pexExcept::RuntimeError, "Unknown substitution: " + key);
107 }
108 ++i;
109 }
110 if (last == std::sregex_iterator()) {
111 _locString = locString;
112 LOGLS_DEBUG(_log, "Copy to: " << _locString);
113 } else {
114 _locString += (*last).suffix().str();
115 LOGLS_DEBUG(_log, "Result: " << _locString);
116 }
117}
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
#define LOGLS_DEBUG(logger, message)
Log a debug-level message using an iostream-based interface.
Definition: Log.h:619
T begin(T... args)
std::string const & locString(void) const
Accessor.
Reports errors that are due to events beyond the control of the program.
Definition: Runtime.h:104
T end(T... args)

Member Function Documentation

◆ locString()

std::string const & lsst::daf::persistence::LogicalLocation::locString ( void  ) const

Accessor.

Definition at line 121 of file LogicalLocation.cc.

121{ return _locString; }

◆ setLocationMap()

void lsst::daf::persistence::LogicalLocation::setLocationMap ( std::shared_ptr< dafBase::PropertySet map)
static

Set the logical-to-less-logical map.

Definition at line 125 of file LogicalLocation.cc.

125 {
126 if (map) {
127 _map = map->deepCopy();
128 } else {
129 _map.reset();
130 }
131}

The documentation for this class was generated from the following files: