From Lazarus wiki
Revision as of 14:54, 11 May 2012 by Chronos (talk | contribs) (syntaxhighlight)

Deutsch (de) | English (en) | français (fr) | italiano (it) | 日本語 (ja)


The TechInsite Object Persistence Framework (tiOPF) is an Open Source framework of Delphi/Object Pascal code that simplifies the mapping of an object oriented business model into a relational database. The framework is mature and robust. It has been in use on production sites for over seven years. It is free, open source, and available for immediate download with full source code.

Some of the key features of the tiOPF include:

  • Lets you build an object oriented application that can swap databases with the flick of a command like a command line parameter or a change of a compiler directive. Currently there are persistence layers for:
    • Interbase via IBX
    • Oracle via DOA
    • MySQL via ZeosLib
    • XML via MSDOM
    • XML via XMLLite
    • Paradox via BDE
    • MSAccess via ADO
    • MSSQLServer via ADO
    • FireBird via FBLib
    • FireBird via SqlDB
    • PostgreSQL via SqlDB
    • HTTP Proxy-Remote (for n-tier applications)
    • Text files (CSV and TAB files)
  • Family of abstract base classes for building a complex object model
  • 27 Persistent Object-aware components for building complex GUIs (Delphi only).
  • Model-GUI-Mediators implementation for enabling any standard GUI component to become Object-aware. MGM currently has mediators defined for: VCL, LCL and fpGUI Toolkit.
  • 1600+ DUnit/fpcUnit tests to guarantee stability
  • 160+ pages of documentation to get you started
  • News groups for support
  • Automated, daily builds and unit testing. This is done under Linux and Windows and uses FPC & Delphi compilers.
  • Lots of demos focusing on specific parts of the framework for easy learning.
  • Cross platform. Currently tested on Windows and Linux (32 & 64-bit).


Peter Hinrichsen - Original Developer.
Graeme Geldenhuys - Ported to Free Pascal.


tiOPF uses a dual license. Developers can use the Mozilla Public License 1.1 or the Modified LGPL license (as used by FPC and Lazarus).


The latest stable release can be found on the tiOPF Download page.
The latest development code can be found on the SubVersion server as follows

svn co https://tiopf.svn.sourceforge.net/svnroot/tiopf/tiOPF2/Trunk Source

NOTE: The tiOPF project has released version 2.3, but this is already rather old. It is recommending to check out the latest development code directly from the repository instead. Currently the download page only has a Windows release available. Hopefully some day a platform independent download will be made available for all supported systems. The latest code can be downloaded from SubVersion though.

An easy way to get the code, is to use the command line svn client as follows. The commands below will checkout the Source, Demos and Docs directories of tiOPF version 2.

mkdir tiOPF2
cd tiOPF2
svn co https://tiopf.svn.sourceforge.net/svnroot/tiopf/tiOPF2/Trunk Source
svn co https://tiopf.svn.sourceforge.net/svnroot/tiopf/tiOPF2_Demos Demos
svn co https://tiopf.svn.sourceforge.net/svnroot/tiopf/tiOPF2_Docs Docs

Try and keep the above directory layout. It is much easier to support and the documentation build scripts will work without modification. The Source checkout will download some external links. Most of them are only related to Delphi, but there is one directory called FBLib which is required for the FBLib (Firebird RDMS) support. tiOPF requires a slightly modified version of FBLib 0.85 that adds some extra feature which will hopefully make it into the next FBLib release.

Dependencies / System Requirements

  • Compiler: FPC 2.4.4 or FPC 2.6.0. The latter is used for the hourly unit test builds under Linux.
  • Components for your required persistence layer, if it is not included with the compiler. eg: FBLib for FireBird RDMS.

Status: Stable (Tested on Windows and Linux.)

Issues: None


The Packages

Inside the Source\Compilers\FPC directory there are four packages.

Core units (run-time only package)
GUI related units and components [deprecated] (run-time only package).
Registers/Installs the components into the Lazarus component palette (design-time only package). The GUI components used under Lazarus are still experimental and under heavy development. It is recommended to get frequent updates from SubVersion if they are going to be used. [deprecated]
GUI related units which replaces tiOPFGUI.lpk and does not contain any of the tiOPF custom GUI components. (run-time only package)
Integrates the fpdoc generated help files into Lazarus's help system (design-time only package)

The Setup

  • Unzip the zip file or check out the source from SubVersion to a location of your choice.
  • Open Lazarus
  • Open the package tiOPF.lpk with Component/Open package file (.lpk) located in the Source\Compilers\FPC directory.
  • Click on Compile
  • Open the tiOPFLCL.lpk package and click Compile


  • Open the tiOPFHelpIntegration.lpk package and click Compile and the Install (Lazarus should rebuild and restart).

I included the SqlDB database components as the default persistence layer for Free Pascal in the tiOPF.lpk package. This should run out of the box, because SqlDB in included with the Free Pascal Compiler. If you don't need this persistence layer you can simply disable it as described below.

Persistence layers are controlled by a Compiler Directive under Compiler Options -> Other -> Custom Options. eg: The LINK_FBL directive relates to the FBLib components. The LINK_SQLDB_IB directive relates to the SqlDB (Interbase/Firebird) components. For all the available options see the end of the tiOPFManager.pas unit.

For the Integrated Help to work, Lazarus needs to know how to find the html help files. Please read the tiOPFHelpIntegration.txt file located in \Source\Compilers\FPC for further instructions.


In Lazarus, open your project and add tiOPF as a Required Package (Project -> Project Inspector -> Add). Include tiObject in your uses clause. You are now ready to create objects descending from TtiObject or TtiObjectList.

See the example projects in the Demos directory for additional examples.