LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
lsst::daf::persistence::LogicalLocation Class Reference

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

#include <LogicalLocation.h>

Inheritance diagram for lsst::daf::persistence::LogicalLocation:
lsst::daf::base::Citizen

Public Types

typedef boost::shared_ptr
< LogicalLocation
Ptr
 
- Public Types inherited from lsst::daf::base::Citizen
enum  { magicSentinel = 0xdeadbeef }
 
typedef unsigned long memId
 Type of the block's ID. More...
 
typedef memId(* memNewCallback )(const memId cid)
 A function used to register a callback. More...
 
typedef memId(* memCallback )(const Citizen *ptr)
 

Public Member Functions

 LogicalLocation (std::string const &locString, boost::shared_ptr< dafBase::PropertySet const > additionalData=boost::shared_ptr< dafBase::PropertySet const >())
 
std::string const & locString (void) const
 
- Public Member Functions inherited from lsst::daf::base::Citizen
 Citizen (const std::type_info &)
 
 Citizen (Citizen const &)
 
 ~Citizen ()
 
Citizenoperator= (Citizen const &)
 
std::string repr () const
 Return a string representation of a Citizen. More...
 
void markPersistent (void)
 Mark a Citizen as persistent and not destroyed until process end. More...
 
memId getId () const
 Return the Citizen's ID. More...
 

Static Public Member Functions

static void setLocationMap (boost::shared_ptr< dafBase::PropertySet > map)
 
- Static Public Member Functions inherited from lsst::daf::base::Citizen
static bool hasBeenCorrupted ()
 Check all allocated blocks for corruption. More...
 
static memId getNextMemId ()
 Return the memId of the next object to be allocated. More...
 
static int init ()
 Called once when the memory system is being initialised. More...
 
static int census (int, memId startingMemId=0)
 How many active Citizens are there? More...
 
static void census (std::ostream &stream, memId startingMemId=0)
 Print a list of all active Citizens to stream, sorted by ID. More...
 
static const std::vector
< const Citizen * > * 
census ()
 Return a (newly allocated) std::vector of active Citizens sorted by ID. More...
 
static memId setNewCallbackId (memId id)
 Call the NewCallback when block is allocated. More...
 
static memId setDeleteCallbackId (memId id)
 Call the current DeleteCallback when block is deleted. More...
 
static memNewCallback setNewCallback (memNewCallback func)
 Set the NewCallback function. More...
 
static memCallback setDeleteCallback (memCallback func)
 Set the DeleteCallback function. More...
 
static memCallback setCorruptionCallback (memCallback func)
 Set the CorruptionCallback function. More...
 

Private Attributes

std::string _locString
 The location string. More...
 

Static Private Attributes

static boost::shared_ptr
< dafBase::PropertySet
_map
 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 Storage subclasses.

Definition at line 60 of file LogicalLocation.h.

Member Typedef Documentation

Definition at line 62 of file LogicalLocation.h.

Constructor & Destructor Documentation

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

Constructor from string and additional data.

Definition at line 58 of file LogicalLocation.cc.

59  :
60  lsst::daf::base::Citizen(typeid(*this)), _locString() {
61  boost::regex expr("(%.*?)\\((\\w+?)\\)");
62  boost::sregex_iterator i = make_regex_iterator(locString, expr);
63  boost::sregex_iterator last;
64  pexLog::TTrace<5>("daf.persistence.LogicalLocation",
65  "Input string: " + locString);
66  while (i != boost::sregex_iterator()) {
67  last = i;
68  if ((*i).prefix().matched) {
69  _locString += (*i).prefix().str();
70  }
71  std::string fmt = (*i).str(1);
72  std::string key = (*i).str(2);
73  pexLog::TTrace<5>("daf.persistence.LogicalLocation", "Key: " + key);
74  if (_map && _map->exists(key)) {
75  if (_map->typeOf(key) == typeid(int)) {
76  int value = _map->getAsInt(key);
77  pexLog::TTrace<5>("daf.persistence.LogicalLocation",
78  "Map Val: %d", value);
79  if (fmt == "%") {
80  _locString += (boost::format("%1%") % value).str();
81  }
82  else {
83  _locString += (boost::format(fmt) % value).str();
84  }
85  }
86  else {
87  std::string value = _map->getAsString(key);
88  pexLog::TTrace<5>("daf.persistence.LogicalLocation",
89  "Map Val: " + value);
90  _locString += value;
91  }
92  }
93  else if (additionalData && additionalData->exists(key)) {
94  if (additionalData->typeOf(key) == typeid(int)) {
95  int value = additionalData->getAsInt(key);
96  pexLog::TTrace<5>("daf.persistence.LogicalLocation",
97  "Map Val: %d", value);
98  if (fmt == "%") {
99  _locString += (boost::format("%1%") % value).str();
100  }
101  else {
102  _locString += (boost::format(fmt) % value).str();
103  }
104  }
105  else {
106  std::string value = additionalData->getAsString(key);
107  pexLog::TTrace<5>("daf.persistence.LogicalLocation",
108  "Map Val: " + value);
109  _locString += value;
110  }
111  }
112  else {
113  throw LSST_EXCEPT(pexExcept::RuntimeError,
114  "Unknown substitution: " + key);
115  }
116  ++i;
117  }
118  if (last == boost::sregex_iterator()) {
120  pexLog::TTrace<5>("daf.persistence.LogicalLocation",
121  "Copy to: " + _locString);
122  }
123  else {
124  _locString += (*last).suffix().str();
125  pexLog::TTrace<5>("daf.persistence.LogicalLocation",
126  "Result: " + _locString);
127  }
128 }
static boost::shared_ptr< dafBase::PropertySet > _map
The logical-to-less-logical map.
std::string const & locString(void) const
std::string _locString
The location string.
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
Definition: Citizen.h:56

Member Function Documentation

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

Accessor.

Definition at line 132 of file LogicalLocation.cc.

132  {
133  return _locString;
134 }
std::string _locString
The location string.
void lsst::daf::persistence::LogicalLocation::setLocationMap ( boost::shared_ptr< dafBase::PropertySet map)
static

Set the logical-to-less-logical map.

Definition at line 138 of file LogicalLocation.cc.

138  {
140  if (map) {
141  _map = map->deepCopy();
142  } else {
143  _map.reset();
144  }
145 }
static boost::shared_ptr< dafBase::PropertySet > _map
The logical-to-less-logical map.

Member Data Documentation

std::string lsst::daf::persistence::LogicalLocation::_locString
private

The location string.

Definition at line 71 of file LogicalLocation.h.

dafBase::PropertySet::Ptr lsst::daf::persistence::LogicalLocation::_map
staticprivate

The logical-to-less-logical map.

Definition at line 72 of file LogicalLocation.h.


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