interface

Implement callback function in JNI using Interface

こ雲淡風輕ζ 提交于 2019-12-17 15:51:02
问题 I need to implement callback function in Java using “interface”. I have wrote the application part as MyJavaFunction(int size, m_GetSizeInterface); m_GetSizeInterface is an Interface which contains the callback function GetSize. This GetSize method is override in the application. In JNI I need to call a CPP function having prototype int MyCPPFunction(int size, int (*callback)(int* ID)); How can I pass this GetSize as parameter to MyCPPFunction in JNI? Please help public int GetSize (m

How can I refer to the class type a interface is implementing in Java?

↘锁芯ラ 提交于 2019-12-17 15:46:09
问题 I came to a problem with interfaces in a program I'm making. I want to create a interface which have one of its methods receiving/returning a reference to the type of the own object. It was something like: public interface I { ? getSelf(); } public class A implements I { A getSelf() { return this; } } public class B implements I { B getSelf() { return this; } } I can't use an "I" where it's a "?", because I don't want to return a reference to the interface, but the class. I searched and found

Two interfaces with same method signature implemented in Java class

狂风中的少年 提交于 2019-12-17 15:44:50
问题 I have two Java interfaces and one implementing class. (I have used Eclipse to run the program directly, and I did not try to check any compiler warning et cetera by explicitly compiling from the command line.) Why do they run without problem? Why does Java allow this, even when it satisfies the "contract" of both interfaces but create ambiguity in implementing class? Updated the example. public interface CassettePlayer { void play(); } public interface DVDPlayer { void play(); } public class

Alternatives to static methods on interfaces for enforcing consistency

我们两清 提交于 2019-12-17 15:37:49
问题 In Java, I'd like to be able to define marker interfaces, that forced implementations to provide static methods. For example, for simple text-serialization/deserialization I'd like to be able to define an interface that looked something like this: public interface TextTransformable<T>{ public static T fromText(String text); public String toText(); Since interfaces in Java can't contain static methods though (as noted in a number of other posts/threads: here, here, and here this code doesn't

Decouple unit of work from services or repo

坚强是说给别人听的谎言 提交于 2019-12-17 15:35:11
问题 I am trying to decouple my unit of work from my services or repository so that I wont have to touch the UoW code whenever I wish to add a new service. How do I do this? _categoryService = _unitOfWork.Get<ICategoryService>(); so instead of _unitOfWork.CategoryService.Add(category) I can just say; _categoryService.Add(category); 回答1: I am trying to decouple my unit of work from my services or repository so that I won’t have to touch the UoW code whenever I wish to add a new service Well, that’s

C# Plugin Architecture with interfaces share between plugins

僤鯓⒐⒋嵵緔 提交于 2019-12-17 15:34:52
问题 I divided my problem into a short and a long version for the people with little time at hand. Short version: I need some architecture for a system with provider and consumer plugins. Providers should implement intereface IProvider and consumers should implement IConsumer. The executing application should only be aware of IProvider and IConsumer. A consumer implementation can ask the executing assembly (by means of a ServiceProcessor) which providers implement InterfaceX and gets a List back.

How are java interfaces implemented internally? (vtables?)

天大地大妈咪最大 提交于 2019-12-17 15:27:44
问题 C++ has multiple inheritance. The implementation of multiple inheritance at the assembly level can be quite complicated, but there are good descriptions online on how this is normally done (vtables, pointer fixups, thunks, etc). Java doesn't have multiple implementation inheritance, but it does have multiple interface inheritance, so I don't think a straight forward implementation with a single vtable per class can implement that. How does java implement interfaces internally? I realize that

How to use a user-defined-type in a Fortran interface

半世苍凉 提交于 2019-12-17 14:56:36
问题 In a Fortran 2003 module I'm defining a type called t_savepoint and, later, I want to define an interface for a subroutine called fs_initializesavepoint , which takes an object of type t_savepoint as only argument. Here is the code for the whole module: module m_serialization implicit none type :: t_savepoint integer :: savepoint_index real :: savepoint_value end type t_savepoint interface subroutine fs_initializesavepoint(savepoint) type(t_savepoint) :: savepoint end subroutine fs

What is the idiomatic way in Go to create a complex hierarchy of structs?

女生的网名这么多〃 提交于 2019-12-17 11:55:16
问题 I am writing an interpreter in Go and I am looking for the idiomatic way to store the AST. I read the Go compiler source code and it seems they used interfaces with an empty method to represent the AST. For example, we have the following hierarchy, Object --Immovable ----Building ----Mountain --Movable ----Car ----Bike This is how the above hierarchy is implemented in the "empty method" way. type Object interface { object() } type Immovable interface { Object immovable() } type Building

What is the idiomatic way in Go to create a complex hierarchy of structs?

主宰稳场 提交于 2019-12-17 11:55:01
问题 I am writing an interpreter in Go and I am looking for the idiomatic way to store the AST. I read the Go compiler source code and it seems they used interfaces with an empty method to represent the AST. For example, we have the following hierarchy, Object --Immovable ----Building ----Mountain --Movable ----Car ----Bike This is how the above hierarchy is implemented in the "empty method" way. type Object interface { object() } type Immovable interface { Object immovable() } type Building