TDbiConfigStream Class Reference

Concept I/O of configuration data and equivalent TDbiRegistry objs. More...

#include <TDbiConfigStream.hxx>

Collaboration diagram for TDbiConfigStream:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TDbiConfigStream ()
 TDbiConfigStream (const std::string &SoftwName, const std::string &ConfigName="default", TVldContext vc=TDbiConfigStream::fgDefaultContext, TDbi::Task task=0, const std::string &tableName="SOFTWARE_CONFIGURATION")
virtual ~TDbiConfigStream ()
const TDbiConfigStreamoperator>> (TDbiRegistry *reg)
const TDbiConfigSetGetConfigSet () const
TDbiConfigStreamoperator<< (const TDbiRegistry *reg)
Bool_t IsEmpty ()
TDbiValidityRecGetValidityRec ()
Bool_t Write (UInt_t dbNo=0, const std::string &logComment="", Bool_t localTest=false)

Static Public Attributes

static TVldContext fgDefaultContext

Private Member Functions

 TDbiConfigStream (const TDbiConfigStream &)

Private Attributes

const TDbiConfigSetfCFSet
TDbiResultSetHandle
< TDbiConfigSet
fCFSetTable
 Pointer to ConfigSet table.
TDbiConfigSet fCFSetModified
 Local TDbiConfigSet (empty until/unless filled using operator <<).
TDbiValidityRec fVRec
 Associated validity rec (used when writing back to the database).
std::string fConfigName
 Name of the configuration set.
std::string fSoftwName
 Name of the software system to be configured.

Detailed Description

Concept I/O of configuration data and equivalent TDbiRegistry objs.

Id
TDbiConfigStream.hxx,v 1.1 2011/01/18 05:49:19 finch Exp

Purpose Used to fill/store TDbiRegistry objects. Contact: A.Finch@lancaster.ac.uk

Definition at line 42 of file TDbiConfigStream.hxx.


Constructor & Destructor Documentation

TDbiConfigStream::TDbiConfigStream (  ) 
TDbiConfigStream::TDbiConfigStream ( const std::string &  SoftwName,
const std::string &  ConfigName = "default",
TVldContext  vc = TDbiConfigStream::fgDefaultContext,
TDbi::Task  task = 0,
const std::string &  tableName = "SOFTWARE_CONFIGURATION" 
)
TDbiConfigStream::~TDbiConfigStream (  )  [virtual]

Definition at line 145 of file TDbiConfigStream.cxx.

References SK_DBI_Debug.

00145                                     {
00146 //
00147 //
00148 //  Purpose: Destructor
00149 //
00150 //  Arguments:
00151 //    None.
00152 //
00153 //  Return:    n/a
00154 //
00155 //  Contact:   N. West
00156 //
00157 //  Specification:-
00158 //  =============
00159 //
00160 //  o  Destroy ConfigStream.
00161 
00162 
00163 //  Program Notes:-
00164 //  =============
00165 
00166 //  None.
00167 
00168 
00169   SK_DBI_Debug( "Destroying TDbiConfigStream" << "  ");
00170 
00171 }

TDbiConfigStream::TDbiConfigStream ( const TDbiConfigStream  )  [private]

Member Function Documentation

const TDbiConfigSet* TDbiConfigStream::GetConfigSet (  )  const [inline]

Definition at line 61 of file TDbiConfigStream.hxx.

References fCFSet.

Referenced by operator<<().

00061 { return fCFSet; }

Here is the caller graph for this function:

TDbiValidityRec& TDbiConfigStream::GetValidityRec (  )  [inline]

Definition at line 67 of file TDbiConfigStream.hxx.

References fVRec.

00067 { return fVRec; }

Bool_t TDbiConfigStream::IsEmpty (  )  [inline]

Definition at line 66 of file TDbiConfigStream.hxx.

References fCFSet.

00066 { return fCFSet == 0; }

TDbiConfigStream & TDbiConfigStream::operator<< ( const TDbiRegistry reg  ) 

Definition at line 266 of file TDbiConfigStream.cxx.

References TDbiConfigSet::Clear(), fCFSet, fCFSetModified, fConfigName, fSoftwName, fVRec, TDbiValidityRec::GetAggregateNo(), TDbi::kString, TDbiRegistry::PrintStream(), TDbiConfigSet::PushBack(), TDbiConfigSet::SetAggregateNo(), and SK_DBI_Severe.

00266                                                                       {
00267 //
00268 //
00269 //  Purpose:  Stream configuration data from TDbiRegistry object.
00270 //
00271 //  Arguments:
00272 //
00273 //  Contact:   N. West
00274 //
00275 //  Specification:-
00276 //  =============
00277 //
00278 //  o Refill internal fCFSetModified from reg..
00279 
00280 //  Program Notes:-
00281 //  =============
00282 
00283 //  This does NOT write to the database.  To do that first use this
00284 //  method to refill the configuration and then call the Write method.
00285 
00286   if ( fSoftwName == "" ) {
00287        SK_DBI_Severe( "Cannot fill (<<): No software name defined." << "  ");
00288     return *this;
00289   }
00290 
00291   TDbiFieldType stringType(TDbi::kString);
00292 
00293   ostringstream os;
00294   reg->PrintStream(os);
00295   fCFSetModified.Clear();
00296   fCFSetModified.PushBack("SOFTW_NAME", fSoftwName,  stringType);
00297   fCFSetModified.PushBack("CONFIG_NAME",fConfigName, stringType);
00298   fCFSetModified.PushBack("CONFIG_DATA",os.str(),    stringType);
00299   if ( fVRec.GetAggregateNo() > 0 ) fCFSetModified.SetAggregateNo( fVRec.GetAggregateNo());
00300   fCFSet =  &fCFSetModified;
00301   return *this;
00302 
00303 }

Here is the call graph for this function:

const TDbiConfigStream & TDbiConfigStream::operator>> ( TDbiRegistry reg  ) 

Definition at line 209 of file TDbiConfigStream.cxx.

References TDbiRegistry::Clear(), fCFSet, TDbiConfigSet::GetNumParams(), TDbiConfigSet::GetParamName(), TDbiConfigSet::GetParamValue(), TDbiRegistry::KeysLocked(), TDbiRegistry::LockKeys(), TDbiRegistry::LockValues(), TDbiRegistry::ReadStream(), SK_DBI_Severe, TDbiRegistry::UnLockKeys(), TDbiRegistry::UnLockValues(), and TDbiRegistry::ValuesLocked().

00209                                                                       {
00210 //
00211 //
00212 //  Purpose:  Stream configuration data into TDbiRegistry object.
00213 //
00214 //  Arguments:
00215 //    reg          in    Empty TDbiRegistry object (contents ignored)
00216 //                 out   Filled TDbiRegistry object.
00217 //
00218 //  Return:    Original TDbiConfigStream object.
00219 //
00220 //  Contact:   N. West
00221 //
00222 //  Specification:-
00223 //  =============
00224 //
00225 //  o Erase the contents of reg and refill from the TDbiConfigSet
00226 //    owned by this TDbiConfigStream.
00227 
00228 //  Program Notes:-
00229 //  =============
00230 
00231 //  None.
00232 
00233   if ( ! reg ) return *this;
00234 
00235 //  Record the current state of reg and then clear it.
00236 
00237   Bool_t keysLocked   = reg->KeysLocked();
00238   Bool_t valuesLocked = reg->ValuesLocked();
00239   reg->UnLockKeys();
00240   reg->UnLockValues();
00241   reg->Clear();
00242 
00243 //  Use the owned TDbiConfigSet to fill reg.
00244 
00245   if ( fCFSet ) {
00246     UInt_t numParams = fCFSet->GetNumParams();
00247 
00248 //  Handle configuration tables.
00249 
00250     if ( numParams == 3 && fCFSet->GetParamName(2) == "CONFIG_DATA" ) {
00251       istringstream is(fCFSet->GetParamValue(2));
00252       reg->ReadStream(is);
00253     }
00254     else {
00255          SK_DBI_Severe( "Attempting to fill TDbiRegistry  from a table with "
00256                              << numParams << " columns (should be 3) using column named "
00257                              << fCFSet->GetParamName(2) << " (should be CONFIG_DATA)." << "  ");
00258     }
00259   }
00260   if ( keysLocked   ) reg->LockKeys();
00261   if ( valuesLocked ) reg->LockValues();
00262   return *this;
00263 }

Here is the call graph for this function:

Bool_t TDbiConfigStream::Write ( UInt_t  dbNo = 0,
const std::string &  logComment = "",
Bool_t  localTest = false 
)

Definition at line 308 of file TDbiConfigStream.cxx.

References TDbiCascader::AllocateSeqNo(), TDbiWriter< T >::Close(), fCFSet, fCFSetModified, fConfigName, fSoftwName, fVRec, TDbiValidityRec::GetAggregateNo(), TDbiDatabaseManager::GetCascader(), TDbiTableProxy::GetTableName(), TDbiValidityRec::GetTableProxy(), TDbiDatabaseManager::Instance(), TDbi::kMAXLOCALSEQNO, TDbiConfigSet::SetAggregateNo(), TDbiValidityRec::SetAggregateNo(), TDbiWriter< T >::SetOverlayCreationDate(), TDbiWriter< T >::SetRequireGlobalSeqno(), SK_DBI_Debug, and SK_DBI_Severe.

00310                                                  {
00311 //
00312 //
00313 //  Purpose:  Write configuration data to the database.
00314 //
00315 //  Arguments:
00316 //    dbNo         in    Database number in cascade (starting at 0).
00317 //                         Default: 0.
00318 //    logComment   in    Reason for update.
00319 //                         Default: "".
00320 //    localTest    in    Set true to use local SEQNOs (doesn't require authorising DB).
00321 //                         Default: false.
00322 //
00323 //  Return:        True if I/O successful.
00324 
00325   if ( ! fCFSet ) {
00326        SK_DBI_Severe( "No configuration data to write out." << "  ");
00327     return false;
00328   }
00329 
00330   // If no aggregate number has been asigned so far, but fCFSet non-zero, then must
00331   // be creating a new software/config combination with the data in fCFSetModified.
00332   // Use a global seqno number (or local if localTest) to define a unique aggregate number.
00333   int requireGlobal = localTest ? -1 : 1;
00334   if ( fVRec.GetAggregateNo() < 0 ) {
00335     TDbiCascader& cas = TDbiDatabaseManager::Instance().GetCascader();
00336     Int_t aggNo = cas.AllocateSeqNo(fVRec.GetTableProxy()->GetTableName(),requireGlobal,dbNo);
00337     if ( aggNo <= TDbi::kMAXLOCALSEQNO && ! localTest ) {
00338          SK_DBI_Severe( "Cannot write out configuration data: no authorising entry in cascade." << "  ");
00339       return false;
00340     }
00341     fVRec.SetAggregateNo(aggNo);
00342     fCFSetModified.SetAggregateNo(aggNo);
00343     SK_DBI_Debug( "Aggregate number: " << aggNo
00344                       << " allocated to entry " << fSoftwName
00345                       << "," << fConfigName
00346                       << " in table " << fVRec.GetTableProxy()->GetTableName() << "  ");
00347   }
00348   TDbiWriter<TDbiConfigSet> writer(fVRec,dbNo,logComment);
00349   writer.SetRequireGlobalSeqno(requireGlobal);
00350   writer.SetOverlayCreationDate();
00351   writer << *fCFSet;
00352   return writer.Close();
00353 
00354 }

Here is the call graph for this function:


Member Data Documentation

Pointer to the associated configuration set. May point either to a row of fCFSetTable (or 0) or, after operator <<, to fCFSetModified

Definition at line 81 of file TDbiConfigStream.hxx.

Referenced by GetConfigSet(), IsEmpty(), operator<<(), operator>>(), and Write().

Local TDbiConfigSet (empty until/unless filled using operator <<).

Definition at line 88 of file TDbiConfigStream.hxx.

Referenced by operator<<(), and Write().

Pointer to ConfigSet table.

Definition at line 85 of file TDbiConfigStream.hxx.

std::string TDbiConfigStream::fConfigName [private]

Name of the configuration set.

Definition at line 94 of file TDbiConfigStream.hxx.

Referenced by operator<<(), and Write().

Definition at line 48 of file TDbiConfigStream.hxx.

std::string TDbiConfigStream::fSoftwName [private]

Name of the software system to be configured.

Definition at line 97 of file TDbiConfigStream.hxx.

Referenced by operator<<(), and Write().

Associated validity rec (used when writing back to the database).

Definition at line 91 of file TDbiConfigStream.hxx.

Referenced by GetValidityRec(), operator<<(), and Write().


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

Generated on 11 Aug 2013 for SKDatabase by  doxygen 1.6.1