I’ve created a class for managing the audio of my synth:
class midiSource : public juce::AudioSource
I would like to add it to my mixer. However, the MixerAudioSource class accepts only AudioSource as input. How can I pass midiSource as an input source to my mixer?
(e.g.: mixer.addInputSource(mySource, false);)
Since juce::MixerAudioSource::addInputSource() expects a pointer to a juce::AudioSource, or a subclass of juce::AudioSource, you can just pass &mySource to addInputSource().
Related
I use touchGFX which is a C++ hmi for embedded devcices. I have the following problem and I am not sure how to solve it most effective. I need to access functions in the various StatusBar instances from MyModelListener (see below).
System description:
There is a model which holds the data, the views for the hmi and some presenters which interact between the model and the views. The base classes are automatically generated, I am allowed to modify all class with "My...". All My...Pesenters are linked with the corresponding My...Views by references in both directions.
I have some Presenters:
class MyAPresenter : public MyModelListener;
...
class MyZPresenter : public MyModelListener;
I have some Views belonging to the presenters:
class MyAView: public AViewBase;
...
class MyZView: public ZViewBase;
There is a status bar which should be used in each of the views:
class MyStatusbar : public Statusbar;
AViewBase, ..., ZViewBase each have a protected member instance of class MyStatusbar.
MyAPresenter, ..., MyZPresenter have a reference to MyAView, ..., MyZView.
How can I access (many) functions of MyStatusBar instances (inside the MyAView...) from MyModelListener without introducing as many functions into each MyAView... MyZView?
The data path how status bar can be reached is:
MyModelListener -> MyAPresenter -> MyAView -> AViewBase -> MyStatusbar
Problems:
I cannot access MyStatusbar instances from MyModelListener or MyAView via the AViewBase because MyStatusbar instances are declared protected within AViewBase.
I cannot modifiy AViewBase
I do not want to access MyStatusBar from MyAView..MyZView because I do not want to have all those many functions in each My...View.
I do not want to write all the needed functions in each of MyAPresenter...MyZPresenter.
(All the classes are virtual)
My solution:
Make functions getStatusPtr() returning the address of the Statusbar instances in each of MyAView to MyZView. This is possible because StatusBar is defined protected but not private.
Make virtual getStatusPtr() in each of MyAPresenter to MyZPresenter which calls the getStatusPtr() function in MyAView to MyZView via the owned references.
Define a virtual getStatusPtr() returning 0 in MyModelListener.
Access the StatusBar from MyModelListener if the pointer is not 0. This should deliver the the status bar of A if the MyModelListener functions are called from a MyAPresenter object.
If the View is changed both view and presenter are destroyed and the status bar too. The statusbar thus has to be rebuilt but this is acceptable.
Is there a better/alternative solution?
I have a method with input param as Array. When I generate stub out of it creates List type.
But I want to know how to create a wrapper class around array type e.g. for class Apple it should create ArrayOfApple.
Is there any change needs to be done in class or any specific plugin need to be used?
Note: I am using JAXWS with Apache CXF implementation
Below is the sample code:
EmployeeService.java:
#WebService(endpointInterface="com.test.EmployeeService")
#SOAPBinding(style=Style.DOCUMENT)
public class EmployeeService {
public String updateEmpRoles(#WebParam(name="EmpRoles")EmpRole[] empRoles) {
return "SUCCESS";
}
}
EmpRole.java :
#XmlType(name="EmpRole")
public class EmpRole {
private String empRole;
public String getEmpRole() {
return empRole;
}
public void setEmpRole(String empRole) {
this.empRole = empRole;
}
}
After publishing, wsdl is getting generated as below -
But what I expect is WSDL should create ArrayOfEmpRole and it should wrap List<EmpRole>.
Kindly help
In short - I want something that Björn doesn't want in below link. (In his case, it's automatically creating ArrayOfXXX, this is what I need) - Arrays in SOAP method Parameters generated via JAX-WS?
I would switch from Code first to a Contract first approach which means start with the WSDL and generate a stub using wsdl2java from it. This way you can ensure that the WSDL looks like the way you want.
If you want to stick to the current approach, the easiest way to achieve a wrapper is probably to introduce another class.
I need to populate c++ model from a external source (for example USB). I have registered the model in main.cpp like this,
qmlRegisterType<HardwareDataModel>("org.example", 1, 0, "HardwareDataModel");
I need to change the private member of this HardwareDataModel class from the external source. Because I would like to change the the private data member of this model and fire signal to qml to change the UI. I got stuck how to proceed as I do not know how to populate those private data members. Do I need to instatiate HardwareDataModel in main.cpp? If yes, how to connect the instatiated HardwareDataModel object and one that is qmlRegisteredType (one shown above).
In kernel operations, an OpKernelConstruction pointer is given to the OpKernel constructor, for example
I would like to change some attributes in the context before passing it to the parent constructor.
For example, something like
explicit StreamQueueOp(OpKernelConstruction* context) :
TypedQueueOp(private_modifying_method(context))
But it appears in the description of OpKernelConstruction, that no modifying method exists. Is there a way to modify it?
EDIT:
I want to modify the attributes because I am attempting to make a FIFOQueue that pulls data from a database. I only want the user to have to specify the data stream id and then the queue would hit the database for the shape and type of the data. As such, I want to modify the context to add the shape and type info after I get it from the DB, but before I pass the context onto the base class. The base class makes use of shape and type, so I need to make sure it is in correspondence with the DB.
I'm new to the site (and to c++) so please forgive me if this is a basic question - I've googled and looked through this site without success so far, so any help anyone can provide would be hugely appreciated.
I'd like to add some functionality to an app, that allows a user to fully define the structure and contents of an object. For example, user would be presented with a configuration screen that allows them to list each property of the object - given my limited knowledge I've assumed this might be achieved by using a class:
Class Name: CustomClassName
Class Property 1: property1Name property1DataType property1DefaultValue
...
Class Property n: propertynName propertynDataType propertynDefaultValue
The user would then be able to hit a button to save their custom configuration, and the program could then reference that configuration as a Class:
class CustomClassName
{
property1DataType property1Name = property1DefaultValue;
...
propertynDataType propertynName = propertynDefaultValue;
}
I'm not even sure this is possible using Classes, so if there's another mechanism that facilitates this I'm open to suggestions!
You can't create classes in runtime, but since dynamic typing is in essence a subset of static typing, you can fake it.
Start with the Property type1:
using Property = variant<int, float, string>;
A simple "dynamic" class could look like this:
class DynamicClass {
std::map<std::string, Property> properties;
public:
Property const& operator[](std::string const&) const
Property operator[](std::string const&);
};
Use:
DynamicClass d;
d["myInt"] = 5;
1 Example implementation. Internals of variant should be tailored for your specific purpose. If you need an open variant, where you don't know all of the possible types beforehand, this gets more complicated, calling for something like any.