Event handling + merging of with Poco C++

hi erik

cool ! nice to see that progress

we’ve gotten poco up and running enough to show that it would be good to have. it wont be in 0.05 but it’s next on our list of major changes (and it will be really helpful for addons). it’s too much work for now to bring it in (since the addons are taking most of your energy), but we have looked at it carefully and we’re happy to try adding it to the core. please keep us posted on your progress, and we’ll keep plugging away and keep you up to date on where we’re at.

thanks for suggesting it !!

  • zach

Glad to hear that! I’ve now used the logging, XML parser/writer and FTP functionality as well as some smaller but amazingly useful classes like the Stopwatch. Everything performs really well, and once you’ve worked a bit with it it’s all quite straight forward to use (at least for being c++)… This is for example the amount of code that’s needed to connect to an ftp and upload a file (only poco and std):

void LogController::uploadFile(string file){
string remotePath = “/”;
try{
_ftpClient = new FTPClientSession(_ftpHost, 21);
_ftpClient->login(_ftpLogin, _ftpPassword);
std::ostream& ftpOStream=_ftpClient->beginUpload(remotePath+file);
std::ifstream localIFStream((_logPath+file).c_str(), ifstream::in);
StreamCopier::copyStream(localIFStream, ftpOStream);
_ftpClient->endUpload();
_ftpClient->close();
delete _ftpClient;
_ftpClient=0;
}
catch (Exception& exc)
{
cout << exc.displayText() << endl;
}
}

the code is ripped out of context, just wanted to show that it wouldn’t require much wrapping to become super easy to use ftp addon like

ofFTP.login(string host, int port, string login, string password)
ofFTP.uploadFile(string localFile, string remoteFile)
ofFTP.downloadFile(string localFile, string remoteFile)
ofFTP.logout();

haven’t had time to look into the multi threading stuff yet but it looks promising so it could probably be made to run asynchronously and dispatch events on login and file transfers without too much more work…

it makes a lot of tedious stuff easy and lets you focus on the fun parts, so, yeah, keep plugging it :slight_smile: do understand if you’re busy enough at the moment though…

// e

Thanks so much for this! I just got Poco working and I’m loving it already. This is going to make my life so much easier.

3 things:

  1. I am running on 10.4 – I didn’t have to do the Linking, step 4 and it still works
  2. After compiling, the only thing in poco-1.3.2/Net/include/Poco was the ‘Net’, folder. The ‘DOM’, ‘SAX’, and ‘XML’ folders were in poco-1.3.2/XML/include/Poco
  3. There are great examples in poco-1.3.2/[Whatever lib]/samples

I am very excited about using this library. I haven’t tried out the XML stuff yet, but everything is so straightforward and well documented that I bet it is going to be great.

cool! The dom/sax/xml folders should be where you found them, that was a typo, don’t know how to go back and edit the post…

Another thing I found is that if I drag all the .a files in step 5 then I get compilation errors when including some poco classes (can’t remember which). I remedied this by only using the .a files that doesn’t end with d before the .a extension. So step 5 should be:

Create a new group called poco inside “libs/other libs” in “Groups and Files”
From the finder drag the .a files in the …/poco/lib folder that doesn’t have a d before the .a extension (i.e libPocoNet.a and not libPocoNetd.a) to your poco group (choose relative to project as the reference type).

wonder if the “d” libs are not compiled for debug mode, thus useful if you need to compile OF in debug? worth taking a look at – seeing if your OF project will compile OK in debug / and if you could add those “D” libs for the debug release. We do this w/ rtAudio on visual studio (alternate between debug and release versions of the libs). it’s not always the easiest (that presents some challenges) but it’s useful in case there is a problem in libpoco – the debugger will be able to say what is the offending line, etc… anyway, just a thought.

I’m glad to hear more positive feedback about poco – we’re pretty excited about it.

take care,
zach

I compiled poco on my intel 10.4 machine and uploaded to http://openframeworks.cc/files/poco/poc-…–xcode.zip

I made an install.txt and also included the following examples. They’re straight from the Poco folder (not OF-ized), but I think they are pretty straight forward, and super helpful.

AbstractConfiguration.cpp
Application.cpp
ConfigurationMapper.cpp
ConfigurationView.cpp
dict.cpp
DOMParser.cpp
DOMWriter.cpp
download.cpp
FilesystemConfiguration.cpp
HelpFormatter.cpp
httpget.cpp
IniFileConfiguration.cpp
IntValidator.cpp
LayeredConfiguration.cpp
LoggingConfigurator.cpp
LoggingSubsystem.cpp
Mail.cpp
MapConfiguration.cpp
Option.cpp
OptionCallback.cpp
OptionException.cpp
OptionProcessor.cpp
OptionSet.cpp
PocoLogo.hpp
PrettyPrint.cpp
PropertyFileConfiguration.cpp
RegExpValidator.cpp
SAXParser.cpp
ServerApplication.cpp
Subsystem.cpp
SystemConfiguration.cpp
TimeServer.cpp
Validator.cpp
WinRegistryConfiguration.cpp
WinRegistryKey.cpp
WinService.cpp
XMLConfiguration.cpp

zach: yup, you’re right, the XXXd.a files are for debuging…

I decided to give it a go making a universal (ppc and intel) poco library that links against the 10.4u sdk (so its good for tiger and leopard users)

http://openframeworks.cc/files/poco/poco-universal.zip

I included instructions on how to build the ppc and the intel libraries separately and then use lipo to join them together to make the libs universal binaries. Based on the instructions by erik and jeff.

There is a #define conflict with ofNetwork which we will sort out for 005 - but apart from that it builds and runs fine. Being able to easily download an image via a url and load it into an ofImage object is awesome! I quickly tried sending an email from openFrameworks but I think I had my postfix (smtp server) incorrectly setup.

Cheers,
Theo

Getting poco to work in linux was pretty easy. In Ubuntu, I installed libpoco2, libpoco-dev, and libpoco-doc with apt-get. In my make file, I added -I/usr/include/Poco to the CXXFlags and -lPocoFoundation -lPocoNet (or whatever poco libraries you need to link) to LDFLAGS. In the code, I included the libraries like in their samples: #include “Poco/Net/HTTPRequest.h”

Theo, when you downloaded the image w/ poco and loaded it into ofImage, did you do it by saving it to a file first? Is it possible to load ofImage (or the underlying FreeImage object) from an input stream or whatever you can get back from a poco HTTP request?

Thanks,
Brian

Hey glad to hear!

For loading an image into ofImage I just added an ofstream (not openframeworks) object to reference the file. Then I give the ofstream to poco and it does the rest :smiley:

  
	//some poco stuff  
	HTTPStreamFactory::registerFactory();  
		  
	//specify out url and open stream  
	URI uri("[http://www.coolhunting.com/images/funky2.jpg");		](http://www.coolhunting.com/images/funky2.jpg");		)  
	std::auto_ptr<std::istream> pStr(URIStreamOpener::defaultOpener().open(uri));  
		  
	//create a file to save the stream to  
	ofstream myfile;		  
	myfile.open(ofToDataPath("thumb.jpg").c_str());  
		  
	//copy stream to file  
	StreamCopier::copyStream(*pStr.get(), myfile);  
	myfile.close();  
		  
	//load into an ofImage!  
	img.loadImage(ofToDataPath("thumb.jpg"));  

hey, any chance of getting a codewarrior compiled version? I’d love to try poco but I *do* get scared when I see long lists of errors :slight_smile:

sure -

(a) codewarrior project for poco foundation (note, only the foundation, not net or xml, etc):

http://www.openframeworks.cc/files/poco-…-arrior.zip

(b) simple test of the library (not in OF, just straight c):

http://www.openframeworks.cc/files/poco-…-arrior.zip

it’s actually not so bad to compile, the only thing to understand if you don’t use a makefile, is that it uses a funky conditional cpp include system for different platforms so you have to not include all the src code, and there might be some #defines you have to through somewhere (diff / winmerge my code vs the downloaded code and see if/where they differ). you can probably see from the codewarrior project how to setup the other poco libs (non foundation) if you want to compile them too.

hope that helps!

take care
zach

yay, extremely helpful, as usual. Thanks a lot!

I’ll give a try at compiling the other libs and see how it goes. Thanks for the tips!

hey!

I’ve integrated the example you gave me with of 0.05 with no major problems. I’ve even used cppglue in a test app and everything was ok. It seems really helpful and clean :slight_smile:

However, I’ve found a glitch which I’m not able to solve. If I use any other class in my project that has to include ofMain, I get errors.

Better than copying them here, I’ve stripped down the code and I have a naked codewarrior project that shows them. You have the testapp and a Fonk class. If you comment #include “ofMain” in Fonk.h, it works, but if you leave it uncommented it explodes…

I’ve been scratching my head for a couple of hours now, and don’t know how to solve it, so if could have a look

http://www.jesusgollonet.com/openFramew-…-oco-01.rar

thanks a lot.
best!

hmm - I’ve seen that problem, bt not sure why it happens, it’s definitely codewarrior specific.

can you try commenting out:

//#include <fcntl.h>

from ofSerial.h – I did that and got rid of the error for the meantime. need to do some more research on that :slight_smile:

can you let mek know, does that fix it?

thanks!
zach

yes it seems to work.
For the record, if I uncomment it again nothing works anymore (not even a clean testApp).

anyway, it fixes my problem, as I won’t need ofSerial for this (hmmmm).

Thanks a lot, zach!

from my experience, I think it’s a c/c++ compile issue, you might try “force c++ compilation” in the project options. I actually don’t know if it’s necessary ( can test the other win32 compilers now) and if it’s not, maybe we can just skip it altogether.

glad it’s working !

thanks!!
zach

hi!

The problem persists, even with fcntl commented out. There’s no way I can use a class that includes ofMain outside of testApp. That is, I cannot include openframeworks code twice if I use any poco class.

I get:

undefined identifier memcmp (from cw/guiddef.h)

and 4 illegal function overloading for operators new, delete, new[] and delete[] (from cw/MSL_C++)

I can provide another test example or whatever is needed…

I don’t even know where to start with this, so any help would be super appreciated

thanks a lot!
jesús.

yes please post something a zip with libs and apps ready to compile as one package. I can’t see what’s wrong from the picture.

also, might suggest that you take a moment to look at OF on codeblocks, since we’re (I, personally) are moving away from supporting metroworks. it’s a good compiler, no doubt, but have noticed a bunch of issues like the ones you have now and we can’t maintain them for all compilers, especially for commercial compilers that are not being updated, etc. I know that we’ve (myself, golan, theo, etc) have been using metroworks for a while, because it was a good midpoint betw. VS (massive, powerful and complex) and devcpp (free, simple, and buggy), but we think that CB heads much more towards that middle. It’s completely clean and many of the features (code completion, highlighting, code collapsing, etc) are way ahead of MW.

I don’t think it’d take too long to port over, the hard part’d be any necessary libs. with 05 we give you an allAddonsExample that containts every addon up and running so it’d just be getting poco working on CB (and I’m happy to help w/ that b/c we need it too) and anything else you need to get up and running.

take care!!
zach

thanks, theo, for posting the universal library for poco.

i’ve followed the installation instructions for xcode (2.5) on of_preRelease_v0.05 and am getting a whole slew of errors.

except, i changed the line in the header paths to “…/…/…/libs/poco/include” to reflect the new structure.

/Developer/usr/bin/…/libexec/gcc/i686-apple-darwin8/4.0.1/ld: Undefined symbols:
Poco::DateTimeFormat::HTTP_FORMAT
Poco::DateTimeParser:parse(std::basic_string<char, std::char_traits, std::allocator>char>> const&, int&)

anybody have any thoughts on what might be causing this problem? i tried compiling the libraries myself, as per theo’s instructions, but am still getting those errors.

thanks!

jeremy