GED 2006 (C++)
File detail
Source code
/*
* File: gedplugin.cc - interface for plugins (libGEDplugin)
* Project: GED - bitmap editor (ICP)
* Author: Kamil Dudka, xdudka00
* Team: xdudka00, xfilak01, xhefka00, xhradi08
* Created: 2006-04-04
*/
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include "pluginsupport.h"
#include "gedplugin.h"
using namespace GedPlugin;
/*
* Plugin object initialization
* take arguments of main() function
*/
Plugin::Plugin (int, char *argv[])
{
// Read command-line arguments
for (; 0!= *argv; argv++)
_args.push_back (*argv);
}
/*
* Unused destructor (for now)
*/
Plugin::~Plugin ()
{
}
/*
* Set plugin properties
* desc: reference to PluginDescription object
*/
void Plugin::set (const PluginDescription &desc)
{
_desc = desc;
}
/*
* Execute plugin (if needed)
* return: error-code (0 if success)
*/
int Plugin::exec ()
{
if (_args.size()>=2 && _args[1]=="--name") {
// Plugin identification
switch (_desc.type) {
case TYPE_VOID:
return 1;
case TYPE_FILEFORMAT:
std::cout << "fileformat:";
break;
case TYPE_FILTER:
std::cout << "filter:";
break;
}
std::cout << _desc.name << std::endl;
return 0;
}
int shmID;
char tmp;
if (_args.size()>=2 &&
1==sscanf (_args[1].c_str(), "%i%c", &shmID, &tmp))
{
// Remove shmID from args list
_args.erase (_args.begin() +1);
// Create fb from shared object
SharedFrameBuffer fb (shmID);
// Plugin call
if (int errorCode = _desc.pCore (fb, _args))
return errorCode;
// Commit changes
fb.commit (shmID);
return 0;
}
std::cerr << "libGEDplugin: error: Incorrect plugin call" << std::endl;
return 1;
}