INTRODUCTION
Overview
Download and Install
Quick Start
Documentation
Publications

NONFRAMEWORK CODE
Driver Interfaces
Drivers
Libraries
Utilities

FRAMEWORK CODE
Interfaces
Components
Libraries
Utilities

Full Software Listings

DEVELOPER
Tutorials
Examples
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         

Slice2Log
[UtilitiesLinux]

Generates functions for reading/writing ASCII logs from Slice definition files. More...

Generates functions for reading/writing ASCII logs from Slice definition files.

This utility is used for autogenerating code from Slice definitions.

$ slice2util --help

Generated Logging Functions

Generated Functions

Slice2String generates toString() function for every Slice-defined:

  • Enum
  • Struct
  • Class
  • Sequence
  • Dictionary

Example:

// C++
#include <orcaifacestring/datetime.h>
#include <orcaifacestring/bros1.h>

orca::Time t;
t.seconds = 123;
t.useconds = 45;
cout<<ifacestring::toString( t )<<endl;

orca::Frame2d f;
f.p.x = 1.2;
f.p.y = 3.4;
f.o = 5.6;
cout<<ifacestring::toString( f )<<endl;

This program will produce the following output:

struct orca::Time
seconds = 123
useconds = 45

struct orca::Frame2d
p = struct orca::CartesianPoint2d
  x = 1.2
  y = 3.4
o = 5.6

The signature of the toString() function is the same for all data types. E.g. for a data type Type in Slice module module (e.g. orca), the generated function would have the following signature:

std::string toString( const module::Type& obj, int recurse=1000, int expand=-1, int indent=0 );

where

  • recurse is the number of recursive calls, toString() will make. Default is 1000, i.e. it will most likely recurse through entire type hierarchy.
  • expand is the number of sequence or dictionary elements toString() will print out. Default is -1, which means "all elements".
  • indent determines the number of characters used to indent to top level of the data type. This parameter is incremented as toString() is called recursively.

Examples:

  • Full recursion and full expansion
    // C++
    cout<<ifacestring::toString( scan )<<endl<<endl;
    
    // output
    class orca::RangeScanner2dData
    timeStamp = struct orca::Time
      seconds = 123
      useconds = 45
    ranges = sequence (2)
        [0] 3
        [1] 13
    minRange = 0
    maxRange = 33
    fieldOfView = 77
    startAngle = 13
    
  • No recursion
    // C++
    cout<<ifacestring::toString( scan, 0 )<<endl
    
    // output
    class orca::RangeScanner2dData
    
  • Recursion limited to 1
    // C++
    cout<<ifacestring::toString( scan, 1 )<<endl
    
    // output
    class orca::RangeScanner2dData
    timeStamp = struct orca::Time
    ranges = sequence (2)
        [0] 3
        [1] 13
    minRange = 0
    maxRange = 33
    fieldOfView = 77
    startAngle = 13
    
  • No expansion
    // C++
    cout<<ifacestring::toString( scan, 1000, 0 )<<endl<<endl;
    
    // output
    class orca::RangeScanner2dData
    timeStamp = struct orca::Time
      seconds = 123
      useconds = 45
    ranges = sequence (2)
    minRange = 0
    maxRange = 33
    fieldOfView = 77
    startAngle = 13
    

Generated Logging Functions

Slice2Log generates toLogStream() and fromLogStream() functions for every Slice-defined:

  • Enum
  • Struct
  • Class
  • Sequence
  • Dictionary

The signature of the toLog() function is the same for all data types. E.g. for a data type Type in Slice module module (e.g. orca), the generated function would have the following signature:

void toLogStream( const module::Type& obj, std::ostream& os );
void fromLogStream( module::Type& obj, std::istream& is );

They can be used with std::[i/o]fstream (logging) or std::[i/o]stringstream (easier for testing) objects

Limitations

This tool is limited compared to slice2cpp.

  • Not all types of objects can be used in private data types (i.e. structs, classes, sequences, dictionaries). Specifically no Ice, IceStorm types, etc. are allowed. This limitation stems from the fact that we don't run slice2util on the Ice-supplied types.
    • Orca project: only Orca types are allowed.
    • Satellite projects: only Orca and project types are allowed.
  • There is a limitation when working with derived classes. The following combination is not supported:
    • Holding a pointer to a base class, AND
    • The actual object is a derived class defined in a file different from the base class.
Author:
Alex Makarenko
 

Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)


Generated for Orca Robotics by  doxygen 1.4.5