C++ :: Create A C Wrapper Around A Interface Class?

Mar 14, 2013

I need to create a C Wrapper around a C++_Class and in between needs to be an Interface-Class. The Interface-Class is needed, cause there are more C++_Classes which are kinda equal.

Hierarchicaly it would somehow look like this:

=> XY-Process which is calling the CWrapper
==> CMeasureWrapper.c// <-- CWrapper
===> CMeasureWrapper.h// <-- CWrapper Header
====> IMeasurement.h// <-- Interface-Class
=====> CMeasure.cpp// <-- C++_Class
======> CMeasure.h// <-- C++_Class-Header

My Output after compiling.(files will follow)

// CMeasureWrapper.c | CWrapper
#include "CMeasureWrapper.h"
uint32_t gu32_objectHandle;
uint32_t gu32_measureType;
int32_t addNewMeasureObject(uint32_t u32_measureObjType)
{
int32_t t_status = 0;

[Code]...

It's the first time i'll try to build an CWrapper or even a wrapper. So maybe the Project-Properties need to fit as well.

The project itself is called "Platform" with following settings in:

C/C++ -> Advanced -> Compile As -> "Compile as C++ Code (/TP)"

This property on the CMeasureWrapper.c is switched to:

C/C++ -> Advanced -> Compile As -> "Compile as C Code (/TC)" but only on this file!

I'm not sure if it's necessary, the file is of .c type, so I wasn't sure.

what I am doin wrong? Not just depending on the error output, I mean on the whole project. Is there anything else which will not work with such a combination of CWrapper, Interface and C++_Classes? If there are any questions, just throw them at me

View 2 Replies


ADVERTISEMENT

C++ :: Wrapper Class For DLL?

Jan 27, 2012

I've a plugin (.dll) which converts my CAD models from .mb (Autodesk maya) to .xsi (Softimage) format. To make it work, I start maya application, load plugin (.dll) and convert one at-a-time CAD models to .xsi My question is, can I write a wrapper class in C++ around this .dll, which works as a standalone, and doesn't needs to launch Maya and Convert all the .mb to .xsi ??

and to make things more clear... this .dll is a third party one.... and I'm unaware of its implementation...

View 6 Replies View Related

C :: How To Create Graphical User Interface

Feb 25, 2013

How can i create a graphical user interface using c

View 10 Replies View Related

C++ :: Common Base Class And Abstract Interface Class?

May 28, 2013

I have an abstract base class - let's call it MyInterface - and a class that most classes in my program inherit from, let's call it MyBaseclass.

Let's assume that all my objects inherit MyBaseclass, some of which also inherit MyInterface. Now I want to collect objects in a container class, MyContainerclass. The container class is only interested in objects that implement MyInterface.

Now I know that all objects that inherit MyInterface also inherit MyBaseclass, but the compiler doesn't know that. MyContainerclass wants to call methods in MyBaseclass, but it collects pointers to MyInterface classes. I can't make MyInterface inherit MyBaseclass, because I will be using classes that I don't want to change (they are part of a framework) that already inherit MyContainerclass. IOW, I can't use virtual inheritance to get a nice inheritance diamond.

To sum up, I want to create a container class that:

1. Collects objects that implement MyInterface.

2. Calls MyBaseclass methods on the collected objects.

View 11 Replies View Related

C++ :: Pure Virtual Methods And Interface Class

Jul 11, 2012

I develop add-ons for MS Flight Simulator and I use the poorly documented SDK for this. The SDK provides a .h file in which an interface class is defined (with pure virtual methods only), something like this:

Code:
class IPanelCCallback {
public:
virtual IPanelCCallback* QueryInterface (PCSTRINGZ pszInterface) = 0;
virtual bool ConvertStringToProperty (PCSTRINGZ keyword, SINT32* pID) = 0;
virtual bool ConvertPropertyToString (SINT32 id, PPCSTRINGZ pKeyword) = 0;
};

In my code, I use this interface like this:
Code:
IPanelCCallback* pCallBack = panel_get_registered_c_callback("fs9gps");
...
SINT32 id;
pCallBack->ConvertStringToProperty(propertyName, &id);

Everything works fine, but I don't understand why... I thought the linker would stop with an "undefined symbol" error because the IPanelCCallback methods, such as ConvertStringToProperty, are declared as pure virtual but defined nowhere, and I don't use any library for linking. With such an interface class, I thought I would have to defined a subclass of IPanelCCallback and define the ConvertStringToProperty method.

View 6 Replies View Related

C++ :: Create Simple Input Interface On Console - Allow To Input Values To Variables

Apr 6, 2013

I am trying to create a simple interface on console to allow to input some values to some variables. For ex:

int main() {
double a = 1.5;
double b = 2.5;
double c = 3.5;
string x;

[Code] ....

However, I want these three to display at the same time (now they display one by one), and in the console window I can move the cursor between input place of a, b and c with "arrow key" of keyboard.

View 2 Replies View Related

C++ :: Implement Simple Wrapper For Logging Function

Jul 22, 2014

I need to implement simple wrapper for logging function log(const char *). So the solution is below:

#include <stdio.h>
#include <sstream>
using namespace std;
void log(const char * str){ printf(str);}

[Code] ...

So, according to standard the temporary objects should not be destroyed before full expression execution (expression whitch is not a part of another expression).

The question is: is StreamLogger() << "foo1" << "foo2" << "foo3"; full expression or not?

View 2 Replies View Related

C :: Access C++ Objects By Using Wrapper And Externals - Linking Error

Feb 13, 2013

My goal is accessing c++ objects within c by using wrapper and externals. To get the pointer to the c++ object I use a type "void *".

But i get an error while linking: undefined reference to "create_mycpp".

Should I take an other way to access c++ objects?

Code:
//-------------------------------------
//mycpp.cpp
#include "mycpp.h"
Mycpp::void func(int i)
{
i += 1;

[Code] ....

View 7 Replies View Related

C++ :: PolarSSL SHA512 Wrapper - Differing Hash Lengths

Apr 10, 2013

I'm trying to write a little C++ wrapper around the PolarSLL SHA-512 / 384 implementation, the source code of which you can view here: [URL] .....

The problem I'm having is that the length of the digest is not always 64 bytes (for sha512) or 49 bytes (for sha384) as it's supposed to be, it often is, but not always.

I have pretty much used the code as it is on PolarSSL's website, except for wrapping it in an "impl" namespace. I also ran the self_tests, which all passed.

Here's the code I'm using to wrap the PolarSSL implementation:

namespace {
void sha4(const std::string& input, const sha_t& type, std::string& result) {
bool is_384 = (type == sha_t::SHA_384);
const unsigned char* in = reinterpret_cast<const unsigned char*>(input.c_str());

[Code] ....

When I do a strchr() for '' on the original (non-hex) values, the pointer position returned is the same as the checksums length, so I'm wondering if perhaps the sha4 implementation would shift bits around and one of them happens to become a '', null terminating the hash early?

View 3 Replies View Related

C++ :: How To Create A Class Object Inside Another Class

Feb 20, 2015

My thought is that I would need to establish a variable for the class in the header and call the class within the .cpp file

//class A.h
B b;

Then in class A, to create the object and use a method from the object I would -

//class A.cpp
A::A(){
b();
}
int someAmethod(){
b.bmethod();
}

View 6 Replies View Related

C++ :: How To Create A Singleton Class

Oct 6, 2013

I've tried to program a Singleton class. But the problem is that I don't know how to access the g_pInstance() function. Because this is not working because the constructor and deconstructor is private:

Singleton::g_pInstance()
Code: #include <iostream>
using namespace std;
class Singleton
{

[Code]....

I'm not sure of how to access any object, function, variables in the class when you are using a Singleton. How do you access that?

I'm just asking because I want to know how to do that if I have to use a Singleton sometime when I'm programming.

View 5 Replies View Related

C++ :: How To Create A Container Class

Feb 9, 2013

I know that it's a class that contains data from another class I just do not know how to make them both work together.

View 1 Replies View Related

C++ :: How To Use A String To Create Class Object

Dec 24, 2014

I wanted to create a new class object and I want to name it from a string. Something like this:

string name = "Mike";
Customers name;
//to create a new object in customer class using the name string

Is there any way to do this?

View 11 Replies View Related

C++ :: Cannot Create Struct That Contains Instance Of A Class

Sep 4, 2013

I'm trying to learn as much C++ as I can. I was writing a program that mixes linked lists and classes. There is the class "Obj" which only holds an integer called 'data' and the classic "struct node" structure for linked list, but this time the "node" structure will hold an instance of "Obj" Class and the next* pointer.

#include <iostream>
using namespace std;
class Obj {
private:
int data;
public:

[code]....

View 2 Replies View Related

C++ :: Create A Thread To A Class Function

Jan 25, 2014

I'm trying to create a thread to a class function, but it doesnt work for me...

The function : void Server::RecMsg(SOCKET &socket)

the call : std::thread GetMessages(&Server::RecMsg, ClientSocket);

I get the error : "Error1error C2064: term does not evaluate to a function taking 1 arguments"

View 1 Replies View Related

C++ :: Create Objects From Abstract Class

Oct 13, 2013

I am working on a project that requires me to create objects from a abstract class that has 2 child classes (that need to be derived). Any examples on how to do this? I looked online and the examples were pretty vague. the main error that I am getting is when I make a temp object with & in front of it (such as Employee &genericEmp) it throws a must be initialized error.

View 6 Replies View Related

C++ :: Dynamically Create Class Objects?

Nov 3, 2013

regarding dynamic vector.

Shape2DLink.cpp
void Shape2DLink::InputSensor()
{
string shape,type;

[Code]....

So i'm actually using polyphormism for calculating the area of the cross and other shapes. so how do I actually make use of dynamically create an object this way?

do I create them in my Shape2DLink or in my individual child classes?

View 9 Replies View Related

C/C++ :: Allow User To Create A New Class Instance?

Dec 4, 2014

I am creating a program that allows a user to create multiple 'sequences' and multiple 'filters' and then apply a filter to a sequence.

Each sequence and filter is an array of values.

How do I go about allowing the user to create a 'new' sequence and then store the location so I can access it again later? Once they have created a new sequence they can go on to create another sequence and ten maybe a filter and then another sequence etc etc .. and then they can select sequence 1 and edit the values if they so wish.

They would be asked how many sample values for the sequence, and then I would create a sequence with that many values and an id (1,2,3,4...). They could then enter this id to view/edit the sequence.

The entering/editing values part I am fine with. I just don't know how to allow them to create multiple new instances of a class without using an array so something like..

sequenceClassName somearray[10];
int i;
*create a new array*
somearray[i].create_class(how_many_samples)
i++ //so next sequence they create is 2,3,4.. etc

- this then calls the member function that creates an array using 'sample_values = new float[how_many_samples]' and the user can input their data and edit it whenever by entering the id which will correspond to the somearray[i].

However that approach only allows them to enter a maximum of 11 sequences. It all depends on how big I make that initial array and it just seems like the wrong way to do it.

( how to interact with them, just how to create multiple classes and recall them later to access the data!)

View 2 Replies View Related

C++ :: How To Create Template Method In A Class

Jul 8, 2014

Code:

class A {
public:
template<class T>
ObjectsBase* createObject(T* objType, Ogre::String name, Ogre::Vector3 position);
};
template<class T>
ObjectBase* A::createObject(T* objType, Ogre::String name, Ogre::Vector3 position);

My goal is to create any ObjectBase* derived object and return it to class A....

View 6 Replies View Related

C# :: Static In Interface

Jul 1, 2014

I have the following scenario: I plan to have an xml configuration file.I have a trader that lunch few strategies, each have different configurations. I plan to have all configuration reside in the same file as different nodes.

Now I want that each strategy will hard code the name of node it will loop up for its parameters. Since those paramters are requered for the init and I use DI (configuration are passed in the constructor) I want to make it static.

So this would be something like.

public class Strategy: Base_strategy{
public const string _conf_name = "XXX";
public static string get_conf_name(){

[Code]....

Since other people will code strategies, I want each strategy to implement this static function. I wanted to do this in an interface so that anyone coding new strategy,implementing the base strategy will have to code this static function as part of the contract.

View 5 Replies View Related

C++ :: Create A Class Representing Project Activities

Mar 24, 2013

Create a class representing project activities. In this class include all the required data members and member functions. Each activity should have a record of activity duration, calculated early start, early finish, late start, late finish, free float, and total float. Each activity may or may not maintain a list of its successors and predecessors. Provide your design in UML and implement it in C++ using an interface head file and an implementation source file. I do not understand classes or UML designs.

View 2 Replies View Related

C++ :: Create 5 Instance Object Of Class Test?

Apr 27, 2014

I am new to C++. I am trying to create 5 instance object of class Test. I wonder if these two codes are the same.

Test testArray[5];
//which one is the correct way or what is the correct way?
for(i=0;i<5;i++)
{
Test testArray;
}

View 2 Replies View Related

C++ ::  How To Create Global Object / Instance Of A Class

Aug 25, 2013

I'm new in object oriented programming. I need creating a global object/instance of a class, that can be used by any function.

View 19 Replies View Related

C++ :: Class Constructor To Create Date And Time?

Mar 13, 2014

I am trying to create two classes: a Date class and a Time class. The Date class has to have three private data members: day, month and year. The Time class should have two private data members:hour and minute. Each class should have two member functions: a constructor and display. I am lost and my code won't run ....

class Date {
private:
int month, day, year;
public:
Date(int m, int d, int y){
month = m;
day = d;
year = y;

[code]....

View 2 Replies View Related

C/C++ :: How To Interface Database With ATM Project

Jun 5, 2014

I had a project to create an ATM with a database of 100 customers, i wasn't able to interface the real program with the database. I have submitted the project already. Here is the database and the ATM program

#include <stdio.h>
int main(void) {
int account, pin;

[Code]....

View 1 Replies View Related

C/C++ :: Use Analog Device Through USB Interface

Sep 25, 2014

I am supposed to write a C program to send through USB interface to the analog device AD9914. Now I am doing the USB interface part where my computer has to detect the AD when it is plugged in and send the signals to it. I have to write the program to detect the device when it is plugged in. What kind of functions can I use? I know that the registry stores the device when it is plugged in. What functions are available to read?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved