Leosac  0.8.0
Open Source Access Control
Leosac::Audit::IAuditEntry Class Referenceabstract

Base interface to Audit object. More...

#include <IAuditEntry.hpp>

+ Inheritance diagram for Leosac::Audit::IAuditEntry:
+ Collaboration diagram for Leosac::Audit::IAuditEntry:

Public Member Functions

 MAKE_VISITABLE ()
 
virtual AuditEntryId id () const =0
 Retrieve the identifier of the entry. More...
 
virtual void finalize ()=0
 Mark the entry as finalized, and update it wrt the database. More...
 
virtual bool finalized () const =0
 Is this entry finalized. More...
 
virtual void reload ()=0
 Reload the object from the database. More...
 
virtual void event_mask (const EventMask &mask)=0
 Set the event mask for the entry. More...
 
virtual const EventMaskevent_mask () const =0
 Retrieve the current event mask. More...
 
virtual void author (Auth::UserPtr user)=0
 Set the author of the entry. More...
 
virtual Auth::UserId author_id () const =0
 Retrieve the user id of the author of this entry. More...
 
virtual void set_parent (IAuditEntryPtr parent)=0
 Set parent as the parent audit entry for this entry. More...
 
virtual IAuditEntryPtr parent () const =0
 Retrieve the parent of this entry. More...
 
virtual void remove_parent ()=0
 Remove the parent-child relationship between this entry and its parent. More...
 
virtual size_t children_count () const =0
 Returns the number of children that this entry has. More...
 
virtual boost::posix_time::ptime timestamp () const =0
 Retrieve unix timestamp. More...
 
virtual std::string generate_description () const
 Generate a description for this event. More...
 
virtual size_t version () const =0
 Returns the ODB version of the object. More...
 
- Public Member Functions inherited from Leosac::Tools::IVisitable
virtual void accept (::Leosac::Tools::BaseVisitor &)=0
 Accept a visitor that may mutate this. More...
 
virtual void accept (::Leosac::Tools::BaseVisitor &) const =0
 Accept a visitor that will not mutate this. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from Leosac::Tools::IVisitable
template<class T >
static bool visitor_dispatch (T &visited, BaseVisitor &visitor, bool abort_on_failure)
 

Detailed Description

Base interface to Audit object.

This interface is inherited by all "behavior specific" audit object, such as IWSAPICall (when a websocket API call is made) or IUserEvent when something happens to a user.

There are 2 main reasons for using an interface here:

  • It reduces the required include for files that will use Audit object. Indeed, only the interface file and the AuditFactory header are required. No need to include various ODB headers.
  • Allows us the use of factory function to create Audit object. This provides stronger garantee against bugs, as part of the object lifecycle is managed the factory function.

Definition at line 47 of file IAuditEntry.hpp.

Member Function Documentation

◆ author()

virtual void Leosac::Audit::IAuditEntry::author ( Auth::UserPtr  user)
pure virtual

Set the author of the entry.

The author is the user that is responsible (aka at the source) of the event.

Pre-Conditions:

  • The user pointer, if not null, must point to an already persisted user object.

Implemented in Leosac::Audit::AuditEntry.

◆ author_id()

virtual Auth::UserId Leosac::Audit::IAuditEntry::author_id ( ) const
pure virtual

Retrieve the user id of the author of this entry.

It may returns 0, which is not a valid user_id.

Implemented in Leosac::Audit::AuditEntry.

◆ children_count()

virtual size_t Leosac::Audit::IAuditEntry::children_count ( ) const
pure virtual

Returns the number of children that this entry has.

Implemented in Leosac::Audit::AuditEntry.

◆ event_mask() [1/2]

virtual const EventMask& Leosac::Audit::IAuditEntry::event_mask ( ) const
pure virtual

Retrieve the current event mask.

Implemented in Leosac::Audit::AuditEntry.

◆ event_mask() [2/2]

virtual void Leosac::Audit::IAuditEntry::event_mask ( const EventMask mask)
pure virtual

Set the event mask for the entry.

Parameters
mask

Implemented in Leosac::Audit::AuditEntry.

◆ finalize()

virtual void Leosac::Audit::IAuditEntry::finalize ( )
pure virtual

Mark the entry as finalized, and update it wrt the database.

Calling finalize() on an already finalized entry has no effect.

Subclasses must prevent modification of every attributes once this method has been called.

Pre-Conditions:

  • Must be in a database transaction.
Warning
While updating the object state in the database, the transaction itself is not commit()ed. Make sure to commit the transaction to guarantee that the audit is stored in the database.

Implemented in Leosac::Audit::AuditEntry.

◆ finalized()

virtual bool Leosac::Audit::IAuditEntry::finalized ( ) const
pure virtual

Is this entry finalized.

Implemented in Leosac::Audit::AuditEntry.

◆ generate_description()

virtual std::string Leosac::Audit::IAuditEntry::generate_description ( ) const
inlinevirtual

◆ id()

virtual AuditEntryId Leosac::Audit::IAuditEntry::id ( ) const
pure virtual

Retrieve the identifier of the entry.

An id of 0 means that the entry is not persisted yet.

Implemented in Leosac::Audit::AuditEntry.

◆ MAKE_VISITABLE()

Leosac::Audit::IAuditEntry::MAKE_VISITABLE ( )

◆ parent()

virtual IAuditEntryPtr Leosac::Audit::IAuditEntry::parent ( ) const
pure virtual

Retrieve the parent of this entry.

Implemented in Leosac::Audit::AuditEntry.

◆ reload()

virtual void Leosac::Audit::IAuditEntry::reload ( )
pure virtual

Reload the object from the database.

Pre-Conditions:

  • Must be in a database transaction.
Note
Be careful as internal change made to the object will be lost when reload()ing the object.

Implemented in Leosac::Audit::AuditEntry.

◆ remove_parent()

virtual void Leosac::Audit::IAuditEntry::remove_parent ( )
pure virtual

Remove the parent-child relationship between this entry and its parent.

This effectively also remove this from the children of its current parent.

Note
This is a no-op is there is already no parent.

Implemented in Leosac::Audit::AuditEntry.

◆ set_parent()

virtual void Leosac::Audit::IAuditEntry::set_parent ( IAuditEntryPtr  parent)
pure virtual

Set parent as the parent audit entry for this entry.

The set_parent() will copy the parent's author to this->author_ if there currently is no author assigned to the entry.

Pre-Conditions:

  • Shall be already persisted (otherwise we might give the parent a non persisted child, resulting in foreign key issue).
  • Shall have no parent.
  • The parent must be a non-null, already persisted object.
  • parent must be of type AuditEntryPtr. This should always be the case.

Post-Conditions:

  • Will have a parent.
  • This object will be somewhere in parent->children_ array.

Implemented in Leosac::Audit::AuditEntry.

◆ timestamp()

virtual boost::posix_time::ptime Leosac::Audit::IAuditEntry::timestamp ( ) const
pure virtual

Retrieve unix timestamp.

Implemented in Leosac::Audit::AuditEntry.

◆ version()

virtual size_t Leosac::Audit::IAuditEntry::version ( ) const
pure virtual

Returns the ODB version of the object.

This call is for debugging purpose.

Implemented in Leosac::Audit::AuditEntry.


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