ATLAS Offline Software
Loading...
Searching...
No Matches
DbDomainObj Class Reference

Db objects: DbDomainObj. More...

#include <DbDomainObj.h>

Inheritance diagram for DbDomainObj:
Collaboration diagram for DbDomainObj:

Public Types

typedef DbAccessObj< std::string, DbDatabaseObj > Base
 Type definitions.
typedef std::map< std::string, DbDatabaseObj * > Keys
typedef Keys::iterator iterator
typedef Keys::const_iterator const_iterator

Public Member Functions

 DbDomainObj (ITechFactory *imp, const DbType &typ, Io::IoFlag mode=Io::READ)
 Constructor.
virtual ~DbDomainObj ()
 Standard destructor.
ITechDomain * info ()
 Access to technology dependent implementation.
const ITechDomain * info () const
void setAgeLimit (int value)
 Set the maximal allowed age limit for files in this domain.
int ageLimit () const
 Access the maximal age limit.
StatusCode open (Io::IoFlag mode)
 Open domain with possible change of access mode.
StatusCode open ()
 Open domain in default access mode.
StatusCode close ()
 Close domain.
StatusCode ageOpenDbs ()
 Increase the age of all open databases.
StatusCode closeAgedDbs ()
 Check if databases are present, which aged a lot and need to be closed.
StatusCode setOption (const DbOption &refOpt)
 Set domain specific options.
StatusCode getOption (DbOption &refOpt) const
 Access domain specific options.
 DbAccessObjBase (const std::string &n, Io::IoFlag m, const DbType &t, ITechFactory *s=0)
 Constructor from the base class.
size_t size () const
 Object size.
void clearEntries ()
 Object cleanup: remove all entries.
const DbDatabaseObj * find (const std::string &key) const
 Find object by key (CONST).
StatusCode add (const std::string &key, DbDatabaseObj *val)
 Add entry to container.
StatusCode remove (const DbDatabaseObj *val)
 Remove entry from container.
iterator begin ()
iterator end ()
const std::string & name () const
 Access the instance name.
void setName (const std::string &n)
 Access the instance name.
Io::IoFlag mode () const
 Access mode.
void setMode (Io::IoFlag m)
 Set Access mode.
const DbType & type () const
const ITechFactory * techFactory () const
 Allow access to the Database implementation.
ITechFactory * techFactory ()
int refCount () const
 Access reference counter.
int addRef () const
 Add reference count.
int release () const
 Remove reference count.
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

Private Member Functions

void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

int m_maxAge
 Maximal age of files allowed.
ITechDomain * m_info
 Technology dependent stuff.
Keys m_keys
 Key entry buffer.
std::atomic< int > m_refCount
 Reference counter.
Io::IoFlag m_mode
 Access mode.
std::string m_name
 Name of the instance.
DbType m_type
 Database type.
ITechFactory * m_factory
 Pointer to specific pool implementation.
std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels).
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging).

Detailed Description

Db objects: DbDomainObj.

Description: Technology independent part of the Domain implementation

Author
M.Frank

Definition at line 25 of file DbDomainObj.h.

Member Typedef Documentation

◆ Base

typedef DbAccessObj< std::string , DbDatabaseObj > DbAccessObj< std::string, DbDatabaseObj >::Base
inherited

Type definitions.

Definition at line 107 of file DbAccessObj.h.

◆ const_iterator

typedef Keys::const_iterator DbAccessObj< std::string, DbDatabaseObj >::const_iterator
inherited

Definition at line 110 of file DbAccessObj.h.

◆ iterator

typedef Keys::iterator DbAccessObj< std::string, DbDatabaseObj >::iterator
inherited

Definition at line 109 of file DbAccessObj.h.

◆ Keys

typedef std::map< std::string, DbDatabaseObj* > DbAccessObj< std::string, DbDatabaseObj >::Keys
inherited

Definition at line 108 of file DbAccessObj.h.

Constructor & Destructor Documentation

◆ DbDomainObj()

DbDomainObj::DbDomainObj ( ITechFactory * imp,
const DbType & typ,
Io::IoFlag mode = Io::READ )

Constructor.

◆ ~DbDomainObj()

virtual DbDomainObj::~DbDomainObj ( )
virtual

Standard destructor.

Member Function Documentation

◆ add()

StatusCode DbAccessObj< std::string, DbDatabaseObj >::add ( const std::string & key,
DbDatabaseObj * val )
inlineinherited

Add entry to container.

Definition at line 140 of file DbAccessObj.h.

140 {
141 iterator i = m_keys.find(key);
142 if ( m_keys.end() == i ) {
143 m_keys.insert(std::make_pair(key, val));
144 val->addRef();
145 return StatusCode::SUCCESS;
146 }
147 return StatusCode::FAILURE;
148 }
int addRef() const
Add reference count.
Definition DbAccessObj.h:66
Description:

◆ addRef()

int DbAccessObjBase::addRef ( ) const
inlineinherited

Add reference count.

Definition at line 66 of file DbAccessObj.h.

66 {
67#ifdef DEBUG_REFCOUNTS
68 std::cout << typeid(*this).name()
69 << " "
70 << m_name
71 << " Refcount:"
72 << m_refCount+1
73 << std::endl;
74#endif
75 return ++m_refCount;
76 }
const std::string & name() const
Access the instance name.
Definition DbAccessObj.h:51

◆ ageLimit()

int DbDomainObj::ageLimit ( ) const
inline

Access the maximal age limit.

Definition at line 42 of file DbDomainObj.h.

42{ return m_maxAge; }
int m_maxAge
Maximal age of files allowed.
Definition DbDomainObj.h:28

◆ ageOpenDbs()

StatusCode DbDomainObj::ageOpenDbs ( )

Increase the age of all open databases.

◆ begin()

iterator DbAccessObj< std::string, DbDatabaseObj >::begin ( )
inlineinherited

Definition at line 161 of file DbAccessObj.h.

161{ return m_keys.begin(); }

◆ clearEntries()

void DbAccessObj< std::string, DbDatabaseObj >::clearEntries ( )
inlineinherited

Object cleanup: remove all entries.

Definition at line 125 of file DbAccessObj.h.

125 {
126 for( const auto & k : m_keys ) k.second->release();
127 m_keys.clear();
128 }
int release() const
Remove reference count.
Definition DbAccessObj.h:78

◆ close()

StatusCode DbDomainObj::close ( )

Close domain.

◆ closeAgedDbs()

StatusCode DbDomainObj::closeAgedDbs ( )

Check if databases are present, which aged a lot and need to be closed.

◆ DbAccessObjBase()

( const std::string & n,
Io::IoFlag m,
const DbType & t,
ITechFactory * s = 0 )
inherited

Constructor from the base class.

◆ end()

iterator DbAccessObj< std::string, DbDatabaseObj >::end ( )
inlineinherited

Definition at line 163 of file DbAccessObj.h.

163{ return m_keys.end(); }

◆ find()

const DbDatabaseObj * DbAccessObj< std::string, DbDatabaseObj >::find ( const std::string & key) const
inlineinherited

Find object by key (CONST).

Definition at line 130 of file DbAccessObj.h.

130 {
131 const_iterator i = m_keys.find(key);
132 return (m_keys.end() == i) ? 0 : (*i).second;
133 }

◆ getOption()

StatusCode DbDomainObj::getOption ( DbOption & refOpt) const

Access domain specific options.

Parameters
refOpt[IN] Reference to option object
Returns
StatusCode indicating success or failure.

◆ info() [1/2]

ITechDomain * DbDomainObj::info ( )
inline

Access to technology dependent implementation.

Definition at line 37 of file DbDomainObj.h.

37{ return m_info; }
ITechDomain * m_info
Technology dependent stuff.
Definition DbDomainObj.h:30

◆ info() [2/2]

const ITechDomain * DbDomainObj::info ( ) const
inline

Definition at line 38 of file DbDomainObj.h.

38{ return m_info; }

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40{
42 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)
int outputLevel(const IMessageSvc *ims, const std::string &source)

◆ mode()

Io::IoFlag DbAccessObjBase::mode ( ) const
inlineinherited

Access mode.

Definition at line 55 of file DbAccessObj.h.

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 167 of file AthMessaging.h.

168{
169 MsgStream* ms = m_msg_tls.get();
170 if (!ms) {
171 if (!m_initialized.test_and_set()) initMessaging();
172 ms = new MsgStream(m_imsg,m_nm);
173 m_msg_tls.reset( ms );
174 }
175
176 ms->setLevel (m_lvl);
177 return *ms;
178}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels).
void initMessaging() const
Initialize our message level and MessageSvc.

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 182 of file AthMessaging.h.

183{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152{
153 // If user did not set explicit message level we have to initialize
154 // the messaging and retrieve the default via the MessageSvc.
155 if (m_lvl==MSG::NIL && !m_initialized.test_and_set()) initMessaging();
156
157 if (m_lvl <= lvl) {
158 msg() << lvl;
159 return true;
160 } else {
161 return false;
162 }
163}

◆ name()

const std::string & DbAccessObjBase::name ( ) const
inlineinherited

Access the instance name.

Definition at line 51 of file DbAccessObj.h.

51{ return m_name; }

◆ open() [1/2]

StatusCode DbDomainObj::open ( )

Open domain in default access mode.

◆ open() [2/2]

StatusCode DbDomainObj::open ( Io::IoFlag mode)

Open domain with possible change of access mode.

◆ refCount()

int DbAccessObjBase::refCount ( ) const
inlineinherited

Access reference counter.

Definition at line 64 of file DbAccessObj.h.

64{ return m_refCount; }

◆ release()

int DbAccessObjBase::release ( ) const
inlineinherited

Remove reference count.

Definition at line 78 of file DbAccessObj.h.

78 {
79 int count = --m_refCount;
80#ifdef DEBUG_REFCOUNTS
81 std::cout << typeid(*this).name()
82 << " "
83 << m_name
84 << " Refcount:"
85 << count
86 << std::endl;
87#endif
88 if ( count == 0 ) {
89 delete this;
90 }
91 return count;
92 }

◆ remove()

StatusCode DbAccessObj< std::string, DbDatabaseObj >::remove ( const DbDatabaseObj * val)
inlineinherited

Remove entry from container.

Definition at line 150 of file DbAccessObj.h.

150 {
151 for (iterator j = m_keys.begin(); j != m_keys.end(); ++j ) {
152 if ( (*j).second == val ) {
153 TYPE* p = (*j).second;
154 m_keys.erase(j);
155 p->release();
156 return StatusCode::SUCCESS;
157 }
158 }
159 return StatusCode::FAILURE;
160 }

◆ setAgeLimit()

void DbDomainObj::setAgeLimit ( int value)
inline

Set the maximal allowed age limit for files in this domain.

Definition at line 40 of file DbDomainObj.h.

40{ m_maxAge = value; }

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29{
30 m_lvl = lvl;
31}

◆ setMode()

void DbAccessObjBase::setMode ( Io::IoFlag m)
inlineinherited

Set Access mode.

Definition at line 57 of file DbAccessObj.h.

57{ m_mode = m; }

◆ setName()

void DbAccessObjBase::setName ( const std::string & n)
inlineinherited

Access the instance name.

Definition at line 53 of file DbAccessObj.h.

53{ m_name = n; }

◆ setOption()

StatusCode DbDomainObj::setOption ( const DbOption & refOpt)

Set domain specific options.

Parameters
refOpt[IN] Reference to option object
Returns
StatusCode indicating success or failure.

◆ size()

size_t DbAccessObj< std::string, DbDatabaseObj >::size ( ) const
inlineinherited

Object size.

Definition at line 121 of file DbAccessObj.h.

121 {
122 return m_keys.size();
123 }

◆ techFactory() [1/2]

Definition at line 62 of file DbAccessObj.h.

62{ return m_factory; }

◆ techFactory() [2/2]

const ITechFactory * DbAccessObjBase::techFactory ( ) const
inlineinherited

Allow access to the Database implementation.

Definition at line 61 of file DbAccessObj.h.

61{ return m_factory; }

◆ type()

const DbType & DbAccessObjBase::type ( ) const
inlineinherited

Definition at line 59 of file DbAccessObj.h.

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging).

Definition at line 141 of file AthMessaging.h.

◆ m_factory

Pointer to specific pool implementation.

Definition at line 41 of file DbAccessObj.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_info

ITechDomain* DbDomainObj::m_info
private

Technology dependent stuff.

Definition at line 30 of file DbDomainObj.h.

◆ m_keys

Keys DbAccessObj< std::string, DbDatabaseObj >::m_keys
privateinherited

Key entry buffer.

Definition at line 114 of file DbAccessObj.h.

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_maxAge

int DbDomainObj::m_maxAge
private

Maximal age of files allowed.

Definition at line 28 of file DbDomainObj.h.

◆ m_mode

Io::IoFlag DbAccessObjBase::m_mode
privateinherited

Access mode.

Definition at line 35 of file DbAccessObj.h.

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels).

Definition at line 132 of file AthMessaging.h.

◆ m_name

std::string DbAccessObjBase::m_name
privateinherited

Name of the instance.

Definition at line 37 of file DbAccessObj.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_refCount

std::atomic<int> DbAccessObjBase::m_refCount
mutableprivateinherited

Reference counter.

Definition at line 33 of file DbAccessObj.h.

◆ m_type

DbType DbAccessObjBase::m_type
privateinherited

Database type.

Definition at line 39 of file DbAccessObj.h.


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