recordstream.h

Go to the documentation of this file.
00001 // OSB library ********************************************* -*- C++ -*-
00013 /*
00014   AUTHOR(S): Manikandan (mk)
00015 
00016   RCS information
00017    $Name: OSB_060808 $
00018    $Revision: 1.47 $
00019 
00020   License
00021    OSB rating and billing library for communication networks
00022    Copyright (C) 2004, 2005, 2006  OSB systems
00023 
00024    This file may be distributed and/or modify under the terms of the
00025    GNU General Public License (GPL) as published by the Free Software
00026    Foundation which is provided in the file LICENSE.GPL included in the
00027    packaging of this file.
00028 
00029    The file is distributed in the hope that it will be useful, but WITHOUT
00030    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00031    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00032    for more details.
00033 
00034    Holders of a OSB Commercial License may use this file under the terms
00035    and conditions of this commercial license.
00036  */
00037 #ifndef _RECORDSTREAM_H_
00038 #define _RECORDSTREAM_H_
00039 
00040 // *********************************************************************
00041 // included header files
00042 // + standard includes
00043 #include <string>
00044 
00045 // + local headers
00046 #include "chrono.h"
00047 #include "osbconst.h"
00048 #include "osberror.h"
00049 #include "osbid.h"
00050 #include "recordstreamdef.h"
00051 
00052 // *********************************************************************
00053 // class declarations
00054 namespace OSB_DB {
00055     class  Session;
00056     struct RecordSourceGw;
00057     struct RecordStreamGw;
00058 }
00059 
00060 namespace OSB_LIB {
00061     class Network;
00062     class NetworkElement;
00063 }
00064 
00065 // ************************************************************************
00066 // namespace extensions
00067 namespace OSB_LIB {
00068 
00069 // ********************************************************************
00070 // class forward declarations
00071    class RecordSource;
00072 
00073 // *********************************************************************
00074 // type definitions
00075 
00076 // *********************************************************************
00077 // class definitions
00078 
00079     // *****************************************************************
00080     // class RecordSource
00084     class RecordSource {
00086         friend struct OSB_DB::RecordSourceGw;
00091         friend struct OSB_DB::RecordStreamGw;
00092     public:
00094         typedef Id<RecordSource> Oid;
00095 
00096     public:
00103         explicit RecordSource(
00104             const Oid& oid = Oid()
00105         ) : oid_(oid) {}
00106 
00116         RecordSource(
00117             const std::string& format,
00118                   ModuleId     generator
00119         );
00120 
00122 
00123 
00124         const Oid& oid() const { return oid_; }
00126         const std::string& name() const { return name_; }
00128         const std::string& format() const { return format_; }
00130         ModuleId processor() const { return processor_; }
00132         ModuleId generator() const { return generator_; }
00134         const Id<Network> networkId() const
00135         {
00136             return Id<Network>(neId_.id1_);
00137         }
00139         const Id2<NetworkElement>& neId() const { return neId_; }
00144         const std::string& directory() const { return directory_; }
00146         const std::string& basename() const { return basename_; }
00148 
00156         std::string filename(long seqNo) const;
00157 
00169         bool read(const OSB_DB::Session& session);
00170 
00171     private:
00173         Oid oid_;
00175         std::string name_;
00177         std::string format_;
00179         ModuleId processor_;
00181         ModuleId generator_;
00183         Id2<NetworkElement> neId_;
00185         std::string directory_;
00187         std::string basename_;
00188     };                                  // class RecordSource
00189 
00190     // *****************************************************************
00191     // class RecordStreamInfo
00195     class RecordStreamInfo {
00197         friend struct OSB_DB::RecordStreamGw;
00198 
00199     public:
00201         typedef Id<RecordStreamInfo> Oid;
00202 
00204         class InvalidSource : public OsbException {
00205             static const ErrorNo errNo_ = 791;
00206         public:
00208             InvalidSource(const RecordStreamInfo& rs);
00209         };
00210 
00217         class InvalidOid : public OsbException {
00218             static const ErrorNo errNo_ = 796;
00219         public:
00223             InvalidOid(const RecordStreamInfo& src);
00224         };
00225 
00226     public:
00236         explicit RecordStreamInfo(const Oid& oid = Oid());
00237 
00254         RecordStreamInfo(
00255             const RecordSource::Oid&  rsId,
00256                   RecordStream::Type  type,
00257                   RecordStream::Media media,
00258             const std::string&        filename = ""
00259         );
00260 
00278         RecordStreamInfo(
00279             const std::string&        format,
00280                   ModuleId            generator,
00281                   RecordStream::Type  type,
00282                   RecordStream::Media media,
00283             const std::string&        filename  = ""
00284         );
00285 
00287 
00288 
00289         const Oid& oid() const { return oid_; }
00291         long seqNo() const { return seqNo_; }
00293         const std::string& filename() const { return filename_; }
00295         long noRecords() const { return noRecords_; }
00297         const DateTime& firstRecord() const { return firstRecord_; }
00299         const DateTime& lastRecord() const { return lastRecord_; }
00301         const Oid& originStreamId() const { return originStreamId_; }
00303         RecordStream::Type streamType() const { return type_; }
00305         RecordStream::Media streamMedia() const { return media_; }
00307         long curRecords() const { return curRecords_; }
00309         long filteredRecords() const { return filteredRecords_; }
00311         long errorRecords() const { return errorRecords_; }
00313         RecordStream::Status status() const { return status_; }
00315         const RecordSource& recordSource() const { return source_; }
00317 
00327         ObjectStatus checkObjVs(
00328             const OSB_DB::Session& session,
00329                   bool             doThrow  = false
00330         ) const;
00331 
00338         void clear();
00339         /*
00340           @brief Reset first and last time stamp.
00341          */
00342         void resetTimeStamps();
00343 
00345 
00346 
00347         void setNoRecords(long noRecords);
00349         void setOriginStreamId(const Oid& orgStreamId);
00351         void setCurRecords(long curRecords);
00353         void setFilteredRecords(long filteredRecords);
00355         void setErrorRecords(long errorRecords);
00357         void setStatus(RecordStream::Status status);
00359 
00368         void onNewRecord(const DateTime& ts);
00369 
00371         void onErrorRecord();
00372 
00374         void onFilteredRecord();
00375 
00387         void setObjVs(const RecordStreamInfo& rhs);
00388 
00390 
00391 
00402         bool read(const OSB_DB::Session& session);
00403 
00419         bool getNext(
00420             const OSB_DB::Session&     session,
00421             const ModuleId             processor,
00422             const RecordSource::Oid&   srcId,
00423                   RecordStream::Status status = RecordStream::rsReady
00424         );
00425 
00442         bool getNext(
00443             const OSB_DB::Session&     session,
00444             const ModuleId             processor,
00445             const std::string&         format     = std::string(""),
00446                   RecordStream::Status status     = RecordStream::rsReady
00447         );
00448 
00465         bool save(const OSB_DB::Session& session);
00466 
00479         bool insert(const OSB_DB::Session& session);
00480 
00495         bool update(const OSB_DB::Session& session);
00496 
00509         bool remove(const OSB_DB::Session& session);
00510 
00528         bool setProcessing(const OSB_DB::Session& session);
00529 
00544         bool updateStatus(const OSB_DB::Session& session);
00546 
00547     private:
00555         void lock(const OSB_DB::Session& session);
00556     private:
00558         Oid oid_;
00560         long objVs_;
00562         long seqNo_;
00570         std::string filename_;
00572         long noRecords_;
00574         DateTime firstRecord_;
00576         DateTime lastRecord_;
00578         Oid originStreamId_;
00580         RecordStream::Type type_;
00582         RecordStream::Media media_;
00584         long curRecords_;
00586         long filteredRecords_;
00588         long errorRecords_;
00590         RecordStream::Status status_;
00592         RecordSource source_;
00593     };                                  // class RecordStreamInfo
00594 
00595 // *********************************************************************
00596 // inline definitions
00597 
00598 }                                       // namespace OSB_LIB
00599 #endif                                  // #ifndef _RECORDSTREAM_H_

Generated on Sat Sep 2 14:06:34 2006 for OSB Library by  doxygen 1.4.7