From mailer-daemon@brunel.ac.uk Thu Aug 15 16:05:15 2002
Return-Path: <l.field@rl.ac.uk>
Delivery-Date: Thu, 15 Aug 2002 16:05:15 +0100
Received: from dori.rl.ac.uk by eros.brunel.ac.uk with SMTP-UK (PP) with SMTP;
          Thu, 15 Aug 2002 16:05:07 +0100
Received: from rl.ac.uk (hepntw103.pp.rl.ac.uk [130.246.41.127]) 
          by dori.rl.ac.uk (8.11.1/8.11.1) with ESMTP id g7FF4dp05376;
          Thu, 15 Aug 2002 16:04:40 +0100
Message-ID: <3D5BC309.7010908@rl.ac.uk>
Date: Thu, 15 Aug 2002 16:04:41 +0100
From: Laurence Field <l.field@rl.ac.uk>
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0rc2) Gecko/20020513
            Netscape/7.0b1
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: "J.Nebrensky J.Nebrensky"@brunel.ac.uk, d.colling d.colling@ic.ac.uk, 
    b.macevoy@ic.ac.uk
CC: a.j.wilson@rl.ac.uk, S.M.Fisher@rl.ac.uk
Subject: R-GMA, boss and cpp
Content-Type: multipart/mixed; boundary="------------010202000109010606040507"
X-Status: 
X-Keywords:                 
X-UID: 348
Status: RO

--------------010202000109010606040507
Content-type: text/plain; charset="us-ascii"

Hi,

I have constructed some skeleton code in cpp for a producer that you can 
look at to help with integrating R-GMA into BOSS.
The code should build and run using the cpp api rpm. I have remade the 
cpp api rpm after finding a few bugs while at IC. The version you should 
use is version 2.2.4-4 This is attached to the mail and will be put on 
our web site by the end of the day.

Install the cpp-api rpm. Copy the four other files to a directory. Type 
make in the directory to complie.

The code creates a new producer of table name ComputerElementQue, this 
is the table name we usually use to test things. If you need to create 
your own table then you will have to edit the SchemaSetup file. An 
example user table is shown at the end of the file. The code should be 
self explanatory and is well commented. To check to see if the producer 
is working I would recommend using pulse.

Hope this is okay for you. Let me know if you need any more help.

Laurence



--------------010202000109010606040507
Content-type: text/plain; name="boss.cpp"
Content-transfer-encoding: 7bit
Content-Disposition: inline;
 filename="boss.cpp"

// An example to show how to implement a simple circular buffer producer
#include "boss.h"

int Boss::SomeFunction() 
{
  
  /*This line creates a new producer of the table called ComputingElementQueue. This should be called before the insert statement.It could be done in the class constructor if the table name is known at that time.*/ 
  producer= new edg::info::CircularBufferProducer ("ComputingElementQueue","",0);
  /*This line sets the buffer size to 10. Which means that 10 rows can be inserted until the buffer starts to be overwritten.*/
  producer->setRemoteBufferSize(10);
  
return 0;
}

int Boss::LaterFunction() 
{
    /*This line inserts a row into the producer. It needs to be called after the producer has been created. This statement is repeated each time a row is inserted into the producer */
  producer->insert("INSERT into ComputingElementQueue VALUES ('a','b','c')");
  return 0;
}

Boss::~Boss(){
  /*cleans up */
  delete producer;
}

int main(int argc, char** argv) {
  
  /*The next couple of lines is used to initialise log4cpp*/
  string initFileName = "./log4cpp.init";
   try {
    log4cpp::SimpleConfigurator::configure(initFileName);
  } catch(log4cpp::ConfigureFailure& f) {
    std::cout << "Log4cpp Configure Problem " << f.what() << std::endl;
    return -1;
  }

  
  Boss* boss;
  boss->SomeFunction();
  boss->LaterFunction();

  cout << "Press a key to end\n";
  string dummy;
  getchar();
  return 0;
}

--------------010202000109010606040507
Content-type: text/plain; name="boss.h"
Content-transfer-encoding: 7bit
Content-Disposition: inline;
 filename="boss.h"

#include "info/CircularBufferProducer.hh"
#include "log4cpp/Category.hh"
#include "log4cpp/SimpleConfigurator.hh"

class Boss {
 public:
 
  // This is the function where the producer will be created
  int  SomeFunction();

  //This is the function where a row will be inserted into the producer
  int  LaterFunction(); 
  ~Boss();
 private:
  //This is a class variable to enble the producer to be used by all funtions in the class
  edg::info::CircularBufferProducer *producer;
};

--------------010202000109010606040507
Content-type: text/plain; name="log4cpp.init"
Content-transfer-encoding: 7bit
Content-Disposition: inline;
 filename="log4cpp.init"

# a simple test config
#
appender root basic file cpp-api.log
priority root DEBUG

--------------010202000109010606040507
Content-type: text/plain; name="Makefile"
Content-transfer-encoding: 7bit
Content-Disposition: inline;
 filename="Makefile"


CFLAGS = $(shell libwww-config --cflags) -I/opt/edg/include/ -I./

LDFLAGS = $(shell libwww-config --libs) -lxerces-c1_7_0 -lcppunit -llog4cpp

LIBPATH=/opt/edg/lib/info


all: boss


boss.o:
	g++ $(CFLAGS) -c boss.cpp

boss: boss.o
	g++ $(LDFLAGS) boss.o $(LIBPATH)/rgma-cpp.a  $(LIBPATH)/librgmautil.a -o boss

clean:
	rm -f boss.o boss *~

[ edg-rgma-api-cpp-2.2.4-4.i386.rpm ]

--------------010202000109010606040507--

