Re: Tutorial to use ObjectHandler outside of QuantLibXL
Posted by Lisa Ann on Aug 19, 2015; 3:30pm
URL: http://quantlib.414.s1.nabble.com/Tutorial-to-use-ObjectHandler-outside-of-QuantLibXL-tp16776p16820.html
Sorry, my bad... I skipped straight Python chapter assuming it was an optional step.
By the way, I now have Python 2.7 installed and I am ready for rebuilding the whole... (just to be sure: uncommented "PYTHON=C:\Python27\python.exe" in ObjectHandler\gensrc\Makefile.vc).
1 rebuild out of 14 fails, and I think that comes from here:
+------------------------------------------------------------------
| NMAKE : fatal error U1077: 'doxygen.exe' : return code '0x1'
| Stop.
| C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(43,5):
| error MSB3073: The command "NMAKE /f Makefile.vc /a" exited with code 2.
+------------------------------------------------------------------
Nevertheless, I wanted to give it a try with this:
/* +------------------------------------------------------------------
* | MyValueObject class derived from ValueObject just
* | to be able to use it in a concrete way
* +------------------------------------------------------------------
*/
#pragma once
#include <oh/objecthandler.hpp>
class MyValueObject : public ObjectHandler::ValueObject
{
public:
MyValueObject(
const std::string& objectId,
const std::string& className,
bool permanent);
~MyValueObject();
virtual std::vector< std::string > getPropertyNamesVector() const;
virtual const std::set< std::string >& getSystemPropertyNames() const;
virtual ObjectHandler::property_t getSystemProperty(const std::string& name) const;
virtual void setSystemProperty(const std::string& name,
const ObjectHandler::property_t& value);
};
// I can paste here implementations if needed...
__________________________________________________________________
/* +------------------------------------------------------------------
* | Main
* +------------------------------------------------------------------
*/
#include <iostream>
#include "MyValueObject.h"
void makeObject(
const std::string& objectID,
const std::string& name)
{
boost::shared_ptr< ObjectHandler::ValueObject > valueObject(new MyValueObject(objectID, name, false));
boost::shared_ptr< ObjectHandler::Object > object(new ObjectHandler::Object(valueObject, false));
ObjectHandler::Repository::instance().storeObject(objectID, object, true);
};
int main()
{
try
{
makeObject("Object1", "Foo");
char tmp;
std::cin >> tmp;
return 0;
}
catch(...)
{
throw "Exception thrown!";
return 1;
}
}
__________________________________________________________________
This fails due to:
+------------------------------------------------------------------
| main.obj : error LNK2001: unresolved external symbol
| "public: static class ObjectHandler::Repository & __cdecl ObjectHandler::Repository::instance(void)"
| (?instance@Repository@ObjectHandler@@SAAAV12@XZ)
| C:\...\MyObjectHandler.exe : fatal error LNK1120: 1 unresolved externals
+------------------------------------------------------------------
I don't think this is linked to the previous build failure, this seems related to singleton declaration of something static... any help? Do you get the same error?