Giter Club home page Giter Club logo

emf4cpp's People

Contributors

asenac avatar dsevilla avatar mdoerfel avatar qvitech avatar srhenning avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

emf4cpp's Issues

unable to resolve the reference

using basic company example during deserializing created UMU.xmi file unable to get reference from one of the fields:

Company_ptr umu (::ecore::as< Company >(eobj));
const auto& lDepartments = umu->getDepartments();
std::cout<<lDepartments.size()<<std::endl;
const auto& manager = lDepartments[0]->getManager();

getManager() return NULL ptr;

UMU.xmi:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<company:Company xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:company="http:///com.example.company.ecore" name="UMU">
<departments number="8515" manager="//@departments.0/@employees.1">
<employees name="Andres Senac">
<phonebookEntry/>
</employees>
<employees name="Diego Sevilla"/>
</departments>
</company:Company>

edited for parsing basic example:

int main(int argc, char* argv[])
{
    CompanyPackage_ptr companyPackage = CompanyPackage::_instance();
    CompanyFactory_ptr companyFactory = CompanyFactory::_instance();

    {
		Company_ptr umu ( companyFactory->createCompany());
        umu->setName("UMU");

        Department_ptr catedraSAES = companyFactory->createDepartment();
        catedraSAES->setNumber(8515);

        Employee_ptr asenac = companyFactory->createEmployee();
        asenac->setName("Andres Senac");

		/* Check if a containment relation properly sets the eContainer() attribute. */
        catedraSAES->getEmployees().push_back(asenac);
		assert( asenac->eContainer() == catedraSAES );

		catedraSAES->getEmployees().remove(asenac);
		assert( asenac->eContainer() == nullptr );

        catedraSAES->getEmployees().push_back(asenac);
		assert( asenac->eContainer() == catedraSAES );
		
        Employee_ptr dsevilla = companyFactory->createEmployee();
        dsevilla->setName("Diego Sevilla");
        catedraSAES->getEmployees().push_back(dsevilla);

		/* Check if a containment relation properly sets the eContainer() attribute. */
		assert( asenac->eContainer() == dsevilla->eContainer() );

		/* Initially there is always no eContainer. */
		PhonebookEntry_ptr phone = companyFactory->createPhonebookEntry();
		assert( phone->eContainer() == nullptr );

		/* Check if a containment relation properly sets the eContainer() attribute. */
		asenac->setPhonebookEntry(phone);
		assert( phone->eContainer() == asenac );

        catedraSAES->setManager(dsevilla);

        umu->getDepartments().push_back(catedraSAES);

        umu->_initialize();

        std::ofstream outfile ("UMU.xmi");
        ecorecpp::serializer::serializer _ser(outfile);
        _ser.serialize(umu);
        outfile.close();
        std::cout<<"Test Passed"<<std::endl;
    }


    ::ecorecpp::MetaModelRepository::_instance()->load(companyPackage);

    ecorecpp::parser::parser _dser;
    EObject_ptr eobj = _dser.load ("UMU.xmi");

    {
		Company_ptr umu (::ecore::as< Company >(eobj));
        const auto& lDepartments = umu->getDepartments();
        std::cout<<lDepartments.size()<<std::endl;
        const auto& manager = lDepartments[0]->getManager();
        
        if (!manager)
            std::cout<<"manager null"<<std::endl;
        const auto& lemployees = lDepartments[0]->getEmployees();
        std::cout<<lemployees.size()<<std::endl;
        std::cout<<lemployees[0]->getName()<<std::endl;
        std::cout<<lemployees[1]->getName()<<std::endl;
    }
}

Ambiguous operations String getFQN(EClassifier this,String separator) and String getFQN(EOperation this,String separator) for param types [Void, String]

Hi,

when trying to generate C++ files for the Xbase.ecore meta model, I'm getting the following exception:

Exception in thread "main" EvaluationException : Ambiguous operations String getFQN(EClassifier this,String separator) and String getFQN(EOperation this,String separator) for param types [Void, String]
	template::EClassHPP.xpt[1681,15] on line 52 'pkg.getFQN("/")'
	template::Main.xpt[1551,71] on line 43 'EXPAND template::EClassHPP::hpp FOREACH EClassifiers.typeSelect(EClass)'
	template::Main.xpt[1093,23] on line 30 'EXPAND package FOR this'

	at org.eclipse.internal.xtend.expression.ast.Expression.evaluate(Expression.java:59)
	at org.eclipse.internal.xpand2.ast.ExpressionStatement.evaluateInternal(ExpressionStatement.java:45)
	at org.eclipse.internal.xpand2.ast.Statement.evaluate(Statement.java:41)
	at org.eclipse.internal.xpand2.ast.ForEachStatement.evaluateInternal(ForEachStatement.java:121)
	at org.eclipse.internal.xpand2.ast.Statement.evaluate(Statement.java:41)
	at org.eclipse.internal.xpand2.ast.FileStatement.evaluateInternal(FileStatement.java:86)
	at org.eclipse.internal.xpand2.ast.Statement.evaluate(Statement.java:41)
	at org.eclipse.internal.xpand2.ast.AbstractDefinition.evaluate(AbstractDefinition.java:178)
	at org.eclipse.internal.xpand2.ast.ExpandStatement.invokeDefinition(ExpandStatement.java:246)
	at org.eclipse.internal.xpand2.ast.ExpandStatement.evaluateInternal(ExpandStatement.java:190)
	at org.eclipse.internal.xpand2.ast.Statement.evaluate(Statement.java:41)
	at org.eclipse.internal.xpand2.ast.AbstractDefinition.evaluate(AbstractDefinition.java:178)
	at org.eclipse.internal.xpand2.ast.ExpandStatement.invokeDefinition(ExpandStatement.java:246)
	at org.eclipse.internal.xpand2.ast.ExpandStatement.evaluateInternal(ExpandStatement.java:226)
	at org.eclipse.internal.xpand2.ast.Statement.evaluate(Statement.java:41)
	at org.eclipse.internal.xpand2.ast.IfStatement.evaluateInternal(IfStatement.java:101)
	at org.eclipse.internal.xpand2.ast.Statement.evaluate(Statement.java:41)
	at org.eclipse.internal.xpand2.ast.IfStatement.evaluateInternal(IfStatement.java:96)
	at org.eclipse.internal.xpand2.ast.Statement.evaluate(Statement.java:41)
	at org.eclipse.internal.xpand2.ast.AbstractDefinition.evaluate(AbstractDefinition.java:178)
	at org.eclipse.xpand2.XpandFacade.evaluate2(XpandFacade.java:62)
	at org.eclipse.xpand2.XpandFacade.evaluate(XpandFacade.java:43)
	at org.csu.emf4cpp.generator.Generator.generate(Generator.java:102)
	at org.csu.emf4cpp.generator.Generator.main(Generator.java:199)
Caused by: java.lang.RuntimeException: Ambiguous operations String getFQN(EClassifier this,String separator) and String getFQN(EOperation this,String separator) for param types [Void, String]
	at org.eclipse.internal.xtend.type.baseimpl.PolymorphicResolver.getFeature(PolymorphicResolver.java:112)
	at org.eclipse.internal.xtend.type.baseimpl.PolymorphicResolver.getExtension(PolymorphicResolver.java:56)
	at org.eclipse.xtend.expression.ExecutionContextImpl$ExtensionsForNameAndTypeCache.createNew(ExecutionContextImpl.java:97)
	at org.eclipse.xtend.expression.ExecutionContextImpl$ExtensionsForNameAndTypeCache.createNew(ExecutionContextImpl.java:1)
	at org.eclipse.internal.xtend.util.Cache.get(Cache.java:26)
	at org.eclipse.xtend.expression.ExecutionContextImpl.getExtensionForTypes(ExecutionContextImpl.java:371)
	at org.eclipse.xtend.expression.ExecutionContextImpl.getExtension(ExecutionContextImpl.java:382)
	at org.eclipse.internal.xtend.expression.ast.OperationCall.evaluateInternal(OperationCall.java:117)
	at org.eclipse.internal.xtend.expression.ast.Expression.evaluate(Expression.java:51)
	... 23 more

I use the following command to generate the C++ classes:

java -jar "org.csu.emf4cpp.generator_2.0.0.jar" -o ../../src/ecore Xbase.ecore

Has anyone an idea why this exception occurs? The causing call should be this one: https://github.com/catedrasaes-umu/emf4cpp/blob/master/org.csu.emf4cpp.generator/src/template/EClassHPP.xpt#L52

I'm not sure if there's a problem with the Xbase meta-model or if I configured the emf4cpp-generator the wrong way.

Thanks in advance for your help!

Regards
Mario

cannot convert ‘ecore::EClass*’ to ‘ecore::EObject*’ for argument ‘1’ to ‘void ecore::intrusive_ptr_release(ecore::EObject*)’

I have tried creating a simple model then generated using the generator available with the "Downloads" section of your project.

But I end up always with this error:

cannot convert ‘ecore::EClass*’ to ‘ecore::EObject*’ for argument ‘1’ to ‘void ecore::intrusive_ptr_release(ecore::EObject*)’

PS: I have also used the compiled libraries from the "master" branch of the git repo as well.

System details:
Linux ubuntu 4.18.0-21-generic
cmake: 3.10.2
boost: 1.65.1.0ubuntu1
g++: 7.4.0-1ubuntu1~18.04
Qt: 5.9.5+dfsg-0ubuntu2.1
JRE: openjdk version "1.8.0_212"

ECORE:

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="root" nsURI="www.bosch.com/root" nsPrefix="root">
  <eClassifiers xsi:type="ecore:EClass" name="Class_1">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="c" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="d" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="Class_2">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="a" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDouble"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="b" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
  </eClassifiers>
</ecore:EPackage>

undefined reference to `qt_version_tag' in "emf4cpp-edate"

When I run ./generator-release.sh I always receive the following error:

System details:
Linux ubuntu 4.18.0-21-generic
cmake: 3.10.2
boost: 1.65.1.0ubuntu1
g++: 7.4.0-1ubuntu1~18.04
Qt: 5.9.5+dfsg-0ubuntu2.1
JRE: openjdk version "1.8.0_212" / with openjdk-11

[ 20%] Built target emf4cpp-edate
Scanning dependencies of target test-edate
[ 20%] Building CXX object emf4cpp.tests/edate/test/CMakeFiles/test-edate.dir/test.cpp.o
[ 20%] Linking CXX executable test-edate
../../../emf4cpp/libemf4cpp-ecore.so.0.0.1: undefined reference to `qt_version_tag'
collect2: error: ld returned 1 exit status
emf4cpp.tests/edate/test/CMakeFiles/test-edate.dir/build.make:98: recipe for target 'emf4cpp.tests/edate/test/test-edate' failed
make[2]: *** [emf4cpp.tests/edate/test/test-edate] Error 1
CMakeFiles/Makefile2:641: recipe for target 'emf4cpp.tests/edate/test/CMakeFiles/test-edate.dir/all' failed
make[1]: *** [emf4cpp.tests/edate/test/CMakeFiles/test-edate.dir/all] Error 2
Makefile:151: recipe for target 'all' failed
make: *** [all] Error 2

Trying to get the library running with Visual Studio 2019

Hi there,
I was successfully compiling the library with VS2019.
But I'm getting runtime problems during the initialization of EcorePackage and EcoreFactory.
(Please note the change in line 179, which was Object_ptr ... casting between intrusive pointers can be problematic for derived classes right?
image

I also noticed that the generated classes do not contain any code for _inverseAdd and _inverseRemove.
Is there any known problem with this 'reverse setup' which Ecore is using. I know from the Java implementation
these two way references between two objects.

This is the function in my Ecore beeing generated:
image

PS) I have already fixed some missing code for handling more complex ecores (with inheritance over multiple ecores).
however I would wait for a running version before I'm sure this is the fix...

Issues with merged pull request #5

Dear Team,

after some time with no response from @qvitech we suggest to revert pull request #5 completely for the following reasons:

  1. The emf4cpp generator cannot be built: org.csu.emf4cpp.generator/src/template/PackageImpl.xpt, line 51 calls the undefined function getFQN2(). Hence the jar file of the generator cannot be built.
  2. Code was added to the ecore implementation outside of a PROTECTED REGION. The ecore implementation itself will be generated during the bootstrap process of the library. Any code outside of PROTECTED_REGIONs will be removed automatically.
  3. The changes in org.csu.emf4cpp.generator/src/template/EClassImplCPP.xpt may seem like an innocent optimization, but it removes the possibility to set/get attributes of base classes via the generic eSet()/eGet() methods of derived instances. Actually we do not see how serialization or deserialization of class hierarchies continues to work at all after this change.

Regards,
Matthias.

Emf4Cpp support XMI

Does EMF4CPP support XMI? Since I only found XMLResourceFactory but not a XMIResourceFactory.

Custom EDatatype not supported

Hello Team,

In the ecore I had created one EDatatype of Input stream with instanceTypeName = java.io.stream which is working in Java generated code but with equivalent C++ instanceTypeName it is not working. Can you provide a solution?

JAVA:
<eClassifiers xsi:type="ecore:EDataType" name="InputStream" instanceTypeName="java.io.stream"/>

C++:
<eClassifiers xsi:type="ecore:EDataType" name="InputStream" instanceTypeName="std::istream"/>

Regards,
Ramakrishnan

Resolving "xmi" namespace

Hi,

I'm trying to parse a XMI file which has a xmi:XMI root node (like shown in the example at https://www.euclideanspace.com/software/information/xml/xmi/index.htm):

<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:types="http://www.eclipse.org/xtext/common/JavaVMTypes" xmlns:xbase="http://www.eclipse.org/xtext/xbase/Xbase">
...
</xmi:XMI>

If I try to parse this file, I get the following error:

terminate called after throwing an instance of 'std::logic_error'
what(): missing package: xmi
Aborted (core dumped)

I think that the reason is that there's no meta model found in the MetaModelRepository for the namespace xmi.

This is the code I'm using to register the meta models in the repository:

::ecorecpp::MetaModelRepository_ptr repository = ::ecorecpp::MetaModelRepository::_instance();

::ecore::EcorePackage_ptr ecorePackage = ::ecore::EcorePackage::_instance();
repository->load(ecorePackage);

::types::TypesPackage_ptr typesPackage = ::types::TypesPackage::_instance();
repository->load(typesPackage);

::xbase::XbasePackage_ptr xbasePackage = ::xbase::XbasePackage::_instance();
repository->load(xbasePackage);

Do I have to add another package to the registry to be able to parse XMI files with a xml:XMI root node?

Thank you in advance!

Best regards,
Mario

read model file based on created meta-model

I created a meta-model, generated the corresponding cpp code, created an xml file corresponding to my meta-model with the extension ".test_meta_model" and want to read this file. What are the steps?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.