File Information
Library: ActiveRecord
Package: ActiveRecord
Header: Poco/ActiveRecord/ActiveRecord.h
Description
The base class for the ActiveRecord class template.
Inheritance
Direct Base Classes: Poco::RefCountedObject
All Base Classes: Poco::RefCountedObject
Known Derived Classes: ActiveRecord, KeylessActiveRecord
Member Summary
Member Functions: attach, context, create, detach, insert, isAttached, isValid, remove, toString, update, withContext
Inherited Functions: duplicate, referenceCount, release
Types Aliases
Ptr
using Ptr = Poco::AutoPtr < ActiveRecordBase >;
Constructors
ActiveRecordBase
ActiveRecordBase() = default;
Destructor
~ActiveRecordBase
~ActiveRecordBase() = default;
Member Functions
attach
void attach(
Context::Ptr pContext
);
Attaches the object to a Context.
context
Context::Ptr context() const;
Returns the Context this object is attached to, or a null pointer if the object has not been attached to a Context.
create
void create(
Context::Ptr pContext
);
detach
void detach();
Detaches the object from its Context.
insert
virtual void insert() = 0;
Inserts a new row in the database with the content of this object. The ID must be 0, and after successful insert, a unique ID is assigned.
isAttached
bool isAttached() const;
Returns true if and only if the object has been attached to a Context, otherwise false.
isValid
virtual bool isValid() const;
Returns true if and only if the object is valid ID, otherwise false.
remove
virtual void remove() = 0;
Deletes the corresponding row in the database.
toString
virtual std::string toString() const = 0;
Returns a string representation of the object for debugging purposes. The default implementation returns the ID.
update
virtual void update() = 0;
Updates the row in the database with the content of this object.
withContext
template < typename T > static Poco::AutoPtr < T > withContext(
Poco::AutoPtr < T > pObj,
Context::Ptr pContext
);