FiReS  0.2.0
FiReS - Filter, Retrieval and Search
FiReS Documentation

FiReS - property management for Filtering, Retrieval and Search

(c) 2014 - 2020. VGLAB / VG-Lab / URJC / UPM

www.vglab.es www.vg-lab.es vg-la.nosp@m.b@vg.nosp@m.-lab..nosp@m.es

Introduction

FiReS is a library that allow registering type-independent properties in objects. FiReS also provides tasks that can use the registered properties for filtering, search, sorting operations over a set of objects.

Dependencies

Boost.Any, Boost.Lexical_Cast, Boost.property_tree and Boost.Spirit are the only required dependencies.

OpenMP and Boost's Unit Test Framework are optional.

Building

FiReS has been succesfully built and used on Ubuntu 16.04, Mac OSX Yosemite and Windows 7/8/10 (Visual Studio 2015 Win64). The following steps should be enough to build it:

1 git clone https://github.com/vg-lab/FiReS.git
2 mkdir FiReS/build && cd FiReS/build
3 cmake .. -DCMAKE_BUILD_TYPE=Release
4 make

How to use it

### Registering properties

1 {c++}
2 class MyClass : public fires::Object
3 {
4 };
5 ...
6 MyClass myObject;
7 myObject.registerProperty( "property1", 3.0f );
8 myObject.registerProperty( "property2", int( 2 ));

### Retrieving properties

1 {c++}
2 float v1 = myObject.getProperty( "property1" ).value( );
3 int v2 = myObject.getProperty( "property2" ).value( );

### Creating notifier/observer

1 {c++}
2 class MyClass : public fires::Object
3 {
4 public:
5  FIRES_OBSERVER_CALLBACK( observerCallback, notifier, propertyLabel )
6  {
7  std::cout << label( ) << ": Hey!" << " object " << notifier->label( )
8  << " updated " << propertyLabel << " to "
9  << notifier->getProperty( "p1" ).value< int >( ) << std::endl;
10  }
11 };
12 ...
13 MyClass o1, o2;
14 o1.label( ) = "o1";
15 o2.label( ) = "o2";
16 o1.registerProperty( "p1", 1 );
17 fires::ObserverManager::addObserver( &o1, "p1", &o2, &MyClass::observerCallback );
18 o1.setProperty( "p1", 2 );
19 // output:
20 // o2: Hey! object o1 updated p1

Sorting

1 {c++}
2 class MyClass : public fires::Object
3 {
4 };
5 
6 int main ( )
7 {
8 
9  MyClass o1, o2, o3, o4;
10 
11  fires::Sort sorter;
12  fires::SortConfig sortConfig;
13  fires::ScalarPropertySorter< float > sfsf;
14  fires::Objects objs;
15 
16  // Register property
17  o1.registerProperty( "p1", 3.1f );
18  o2.registerProperty( "p1", 4.1f );
19  o3.registerProperty( "p1", 1.2f );
20  o4.registerProperty( "p1", 3.1f );
21 
22  // Create the objects container
23  objs.addList( { &o1, &o2, &o3, &o4 } );
24 
25  // Configure sort config
26  sortConfig.addProperty( "p1", &sfsf );
27 
28  // Eval the task
29  sorter.eval( objs, sortConfig );
30 }