I tried to connect my device to android studio, on linux mint cinnamon. But ı have a problem about connecting. When I click run, my device doesn't seen in device list. But in the terminal, my device looks here.

sancaryum@sancaryum-OEM ~/AndroidStudioProjects/CalismalarTemiz1 $ adb devices List of devices attached 5203d51bf497.... device

I activated usb debugging mode and allow connection permissions on phone. Also I tried mtp,ptp connections,restarting ADB Server, reconnect the device,revoke USB Debugging on phone .. etc. I tried a lot of solution ways. But my device doesn't seen in android studio device list.

How can I connect my phone?

I have a simple app, that uses a AlarmManager and a BroadcastReceiver, nothing complicated, the onReceive() displays a toast. For those who dont have a Xiaomi, here is what the screen looks like:

enter image description here

If I swipe the app away, the Receiver method is not called at all, no Toast, no Logs. If I click on the (x) on the bottom side, which kills all the opened apps, everything works flawlessly. Toast displayed, Log written.

I have been trying to solve this problem for two days, with no success, so thats why I turn to You now, as I have no idea why is this happening.

I have overriden every on...() method in the main activity, to check the lifecycle of the app, it looks like this I click on the icon:


And if I kill it by (x) or swiping it away


Any help will be greatly appriciated. I did not include the code, because I think the issue is with the phone. On emulator it works fine. Unfortunately I don't have another phone to try it.

I am new to game development, and i'm struggling a bit with combining the google play service realtime multiplayer functionality in my LibGDX game. I do not find a lot of tutorials regarding this online.

I have downloaded the BaseGameUtils library, and everything is connected (my signIn method works), and i'm using interfaces to combine the android package with my core package.

In my AndroidLauncher, i have this code:

public void startQuickGame() {
    final int MIN_OPPONENTS = 1, MAX_OPPONENTS = 1;
    Bundle autoMatchCriteria = RoomConfig.createAutoMatchCriteria(MIN_OPPONENTS, MAX_OPPONENTS, 0);

    RoomConfig.Builder rtmConfigBuilder = RoomConfig.builder((RoomUpdateListener) this);
    rtmConfigBuilder.setMessageReceivedListener((RealTimeMessageReceivedListener) this);
    rtmConfigBuilder.setRoomStatusUpdateListener((RoomStatusUpdateListener) this);

    //prevent screen from sleeping

    Games.RealTimeMultiplayer.create(gameHelper.getApiClient(), rtmConfigBuilder.build());

I try to use the code in my Menu class:

protected void handleInput() {
    if (Gdx.input.justTouched() && isOnBtn()) {
        try {
        } catch (Exception e) {
        gsm.set(new OnlineMultiplayerState(gsm));

I'm not sure about how i should actually start the game? At this point, everything just go black.

I would also like to use the code for methods like handleSelectPlayersResult(int response, Intent data)

The problem is that when i try to define this method in my interface, it wont work because Intent only work in the Android package (not in core where my interface is). Do you have an suggestion to how i can solve this?

Thank You!


I copied a few lines of codes from another app. I don't received other errors. I don't understand why I'm receiving below errors. I added the errors and piece of code dedicated for this problem. Can you help me to solve those problems? I don't know how to manage it. strong text

I'm receiving below errors:

C:\Users\tomek.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.1.0.aar\aa5557de90d7cc4d1608f64336354d4a\res\values\values.xml Error:(650, 5) error: expected reference but got (raw string) #0e1539. Error:resource style/Base.AlertDialog.AppCompat (aka com.example.majka.musicappmarta:style/Base.AlertDialog.AppCompat) not found. Error:resource style/Base.AlertDialog.AppCompat.Light (aka com.example.majka.musicappmarta:style/Base.AlertDialog.AppCompat.Light) not found. Error:resource style/Base.Animation.AppCompat.Dialog (aka com.example.majka.musicappmarta:style/Base.Animation.AppCompat.Dialog) not found.

For this line is dedicated line:

<style name="Base.ThemeOverlay.AppCompat.Dialog.Alert">
        <item name="windowMinWidthMajor">@dimen/abc_dialog_min_width_major</item>
        <item name="windowMinWidthMinor">@dimen/abc_dialog_min_width_minor</item>



Error:(822) expected reference but got (raw string) #0e1539.
    Error:resource style/Base.ThemeOverlay.AppCompat.Dark.ActionBar (aka com.example.majka.musicappmarta:style/Base.ThemeOverlay.AppCompat.Dark.ActionBar) not found.
    Error:failed linking references.
    Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
    Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
    Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
    Error:Execution failed for task ':app:processDebugResources'.
    > Failed to execute aapt


#0e1539 #111940 @color/foreground_material_light @color/background_material_dark @color/abc_background_cache_hint_selector_material_dark @color/background_floating_material_dark

iF you need the whole code, pls let me know. I'm the beginner, so I would like to be sure, that I'm able to solve this problem. Thank you very much for your help.

I am a newbie and I am trying to create an app. I saw different tutorials and I have create an app based on Fragment. The problem is that I want now add database but I always get an error. I look for similar errors but I didn't find any good answer so I hope you can help me. This is the error I get:

E/SQLiteLog: (1) table mezzi_militari has no column named TYPE
E/SQLiteDatabase: Error inserting TARGA=urkdofd MEZZO=3265959 TYPE=Tattici NUMERO=3265995
                  android.database.sqlite.SQLiteException: table mezzi_militari has no column named TYPE (code 1): , while compiling: INSERT INTO mezzi_militari(TARGA,MEZZO,TYPE,NUMERO) VALUES (?,?,?,?)
                  Error Code : 1 (SQLITE_ERROR)
                  Caused By : SQL(query) error or missing database.
                    (table mezzi_militari has no column named TYPE (code 1): , while compiling: INSERT INTO mezzi_militari(TARGA,MEZZO,TYPE,NUMERO) VALUES (?,?,?,?))

This is the code of the Class DatabaseHelper:

public class DatabaseHelper extends SQLiteOpenHelper {

public static final String DATABASE_NAME = "mezzi.db";
public static final String TABLE_NAME = "mezzi_militari";
public static final String COL_1 = "ID";
public static final String COL_2 = "TYPE";
public static final String COL_3 = "NUMERO";
public static final String COL_4 = "MEZZO";
public static final String COL_5 = "TARGA” ;

public DatabaseHelper(Context context) {

    super(context, DATABASE_NAME, null, 1);
    SQLiteDatabase db = this.getWritableDatabase();

public void onCreate(SQLiteDatabase db) {


public void onUpgrade(SQLiteDatabase db, int i, int i1) {
public boolean insertData(String Tipo, Integer Numero, String Mezzo, String Targa) {

    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues contentValues = new ContentValues();

    long result = db.insert(TABLE_NAME, null, contentValues);
    if (result== -1)
        return false;
        return true;


This is the Fragment in which works the activity:

public class FirstFragment extends Fragment{

View myView;
EditText edit_num, editmezzo, edit_targa, edit_1stInte, edit_2ndInte, M1edit_data, M1motiv, M1lavoraz;
EditText edit_B_matr, edit_B_install, edit_P_Matr, edit_P_mont, edit_P_scad, RV_ultima, RV_scad;
EditText MPVACO_ult, MPVACO_scad;
Button btnInsert;
DatabaseHelper mydb;

public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
    mydb = new DatabaseHelper(getActivity());
    //edit_1stInte= (EditText)find
    edit_num = (EditText)myView.findViewById(R.id.Numero);
    editmezzo = (EditText)myView.findViewById(R.id.Mezzo);
    edit_targa = (EditText)myView.findViewById(R.id.Targa);
    edit_1stInte = (EditText)myView.findViewById(R.id.Primo_inte);
    edit_2ndInte = (EditText)myView.findViewById(R.id.Secondo_inte);
    M1edit_data = (EditText)myView.findViewById(R.id.Data);
    M1motiv = (EditText)myView.findViewById(R.id.Motivazione);
    M1lavoraz = (EditText)myView.findViewById(R.id.Lavorazione);
    edit_B_matr = (EditText)myView.findViewById(R.id.Matricola);
    edit_B_install = (EditText)myView.findViewById(R.id.Installazione);
    edit_P_Matr = (EditText)myView.findViewById(R.id.Matric);
    edit_P_mont = (EditText)myView.findViewById(R.id.Montaggio);
    edit_P_scad = (EditText)myView.findViewById(R.id.scadenza);
    RV_ultima = (EditText)myView.findViewById(R.id.RV_ultima);
    RV_scad = (EditText)myView.findViewById(R.id.RV_scadenza);
    MPVACO_ult = (EditText)myView.findViewById(R.id.MPVACO_ultima);
    MPVACO_scad = (EditText)myView.findViewById(R.id.MPVACO_scadenza);

    return myView;

public void AddData(){
            new View.OnClickListener() {
                public void onClick(View view) {
                    boolean isInserted = mydb.insertData("Tattici",Integer.parseInt(edit_num.getText().toString()),
                            editmezzo.getText().toString(), edit_targa.getText().toString());
                        Toast.makeText(getActivity(), "I dati sono stati inseriti correttamente", Toast.LENGTH_LONG).show();
                       Toast.makeText(getActivity(), "Data not Inserted", Toast.LENGTH_LONG).show();


I thought it is a matter of space but I couldn't find any error!

Hi I try to create an NxM Matrix like in this post: With Gridview and Edittexts In Android Studio, how to use GridView to display a matrix of Text Boxes?

How do I get the value out of my edittexts?

I started using Odoo last year in my final year project to accomplish a project the company has requested which was an Alfresco connector for Odoo,

I spend 4 months developing the solution while learing how to use the Odoo framework, then I have worked for 8 months as an Odoo developer for the same company, just implementing the same solution over and over again for other purposes and doing other tasks which are mainly:

  • Creating models and Customizing views
  • Creating and desinging Jasper reports
  • Writing technical documentations

Honestly, I found the tasks assigned to me very repetitive and didn't find a significant growth potential (in the technical aspect especialy)

The more experienced Odoo developers in the company become functional consultants, which is not my thing (I'm more of a technical guy)

My question is:

Should I give up Odoo development and change to a more technical role using another technology or give Odoo another chance before changing ??

Recently I became very interested in understanding the concept behind deprecation of an API class in Spring projects for my data mining project.

1) I found out that Spring has many API classes though being announced as deprecated it reappears in multiple versions of sourcecode without being removed permanently by it's alternative.

Could anyone please explain the reason behind this?

In case of class XMLBeanFactory, though ApplicationContext is much powerful substitute for it they have not removed it from their code.

2) Has any class thats been deprecated in any version(say if it is deprecated in version 1.0.0.) been undeprecated again for interesting reasons?

Note: I'm not sure if the way I phrase the question initially will fit 100% on this board, so please help me to focus on the main point.

Scenario: You develop an algorithm or a neural network that performs a certain task, in the case of the algorithm in many steps that use input from the previous step(s) to compute some output. Then you want to evaluate this algorithm, maybe benchmark it under different circumstances, with differing inputs. In the case of the NN you experiment with precisely what information you provide as inputs, in the case of the algorithm maybe you have to debug it, so you want to be able to run the whole algorithm, a certain step i in isolation, and steps i to j.

Now when I did this in the past, this resulted in a lot of very messy and copy-paste heavy imperative code. Is there a way to use OO, maybe through inheritance or composition, to reduce this complexity and avoid having 20 versions of the same method that just run your algorithm?

I am using Firebase Authentication using the mobile number on my app, and I am using the firebase_auth_uid.

My issue when the user un-install the app then installed it and trying to sign-up using, it will trigger the callback onVerificationCompleted but the credential does not have code

FirebaseUser currentUser = mAuth.getCurrentUser();

return null


FirebaseUser mUser = FirebaseAuth.getInstance().getCurrentUser();

return null

please check the following code:

            public void onVerificationCompleted(PhoneAuthCredential credential) {
                Log.d(TAG, "onVerificationCompleted:" + credential);
                // [START_EXCLUDE silent]

                mVerificationInProgress = false;

                FirebaseUser currentUser = mAuth.getCurrentUser();

                if (currentUser != null) {

                } else {
                    if (credential != null &&
                            credential.getSmsCode() != null) {

                    } else {
                        FirebaseUser mUser = FirebaseAuth.getInstance().getCurrentUser();
                        if (mUser != null) {

                                    .addOnCompleteListener(new OnCompleteListener<GetTokenResult>() {
                                        public void onComplete(@NonNull Task<GetTokenResult> task) {
                                            if (task.isSuccessful()) {
                                                String idToken = task.getResult().getToken();

                                                // Send token to your backend via HTTPS
                                                // ...
                                            } else {
                                                // Handle error -> task.getException();
                                                Toast.makeText(hostActivity, "Connection error", Toast.LENGTH_SHORT).show();

                        } else {
                            Toast.makeText(hostActivity, "Connection error", Toast.LENGTH_SHORT).show();
                //updateUI(STATE_VERIFY_SUCCESS, credential);

how can I get the firebase authentication id?

I have an Android app and I'm doing some A/B test experiments to see how the store listing text performs.

In one of my test I changed the logo image. The problem is that I have the same logo image inside my app, as a resource file. It is shown on the splash screen during loading. Both A and B test are serving the same APK of course so it may be confusing for users on B to see a given logo on the store listing and then a different one on the actual app.

How can I solve this? I suspect the only option available is to remove the logo image from the APK or just ignore the problem

Two Installations of Android Studio

I upgraded my Android Studio to 3.1 from 3.0.1 and what I now see is two different install shortcuts. How do I deal with this? My OS is Ubuntu 16.04.1

This is my package json. enter image description here

enter image description here

When trying to run my app on adnroid simulator(with android studio) I get this weird error:

enter image description here

I can not seem to find what is the cause of this.

I struggle with a filtering problem, because my custom filter works only one way. Let me explain it: so I have implemented custom search bar and it takes input from the user then it passes it to the filter. But the problem is that it works only one way, so let's say that I type "s" and all products containing "s" in their name appear. Then I add "h", so we have "sh" in the search bar, so there are displayed products that have "sh" in their name. It all starts when I delete one or all letters. Then I get an empty list, so my ListView is empty as well.

Log after typing "s":

D/ProductActivity: onTextChanged: starting.
D/ProductActivity: performFiltering: starting...
D/ProductActivity: performFiltering: charSequence s
D/ProductActivity: afterTextChanged: starting.
D/ProductAdapter: publishResults: publishing results...
D/ProductAdapter: the list size 14

Log after typing "h", and having "s" already, so "sh":

D/ProductActivity: onTextChanged: starting.
D/ProductAdapter: performFiltering: starting...
D/ProductAdapter: performFiltering: charSequence sp
D/ProductActivity: afterTextChanged: starting.
D/ProductAdapter: publishResults: publishing results...
D/ProductAdapter: the list size 4

When I clear "h", and again have only letter "s" left in the search bar, nothing changes:

D/ProductActivity: onTextChanged: starting.
D/ProductActivity: performFiltering: starting...
D/ProductActivity: performFiltering: charSequence s
D/ProductActivity: afterTextChanged: starting.
D/ProductAdapter: publishResults: publishing results...
D/ProductAdapter: the list size 4

And now when I click the button that clears all typed letter in the searchbar:

D/ProductActivity: beforeTextChanged: starting.
D/ProductAdapter: performFiltering: charSequence 
D/ProductAdapter: performFiltering: tempList size 0
D/ProductActivity: onTextChanged: starting.
D/ProductAdapter: performFiltering: starting...
D/ProductAdapter: performFiltering: charSequence 
D/ProductAdapter: performFiltering: tempList size 0
D/ProductActivity: afterTextChanged: starting.
D/ProductAdapter: publishResults: publishing results...
D/ProductAdapter: the list size 0
D/ProductAdapter: publishResults: publishing results...
D/ProductAdapter: the list size 0

It seems to me that the main product list doesn't want to come back to its starting position. Here is the code taken from my cutom adapter class:

class CustomFilter extends Filter {

    protected FilterResults performFiltering(CharSequence charSequence) {
        FilterResults filterResults = new FilterResults();
        Log.d(TAG, "performFiltering: starting...");
        Log.d(TAG, "performFiltering: charSequence " + charSequence);

        if (charSequence != null && charSequence.length() > 0) {
            charSequence = charSequence.toString().toUpperCase();

            List<Product> filters = new ArrayList<>();

            for (int i = 0; i < tempList.size(); i++) {
                if (tempFoodList.get(i).getFoodName().toUpperCase().contains(charSequence)) {
                    Product product = new Product(tempList.get(i).getName(), tempList.get(i).getPrice());

            filterResults.count = filters.size();
            filterResults.values = filters;
        } else {
            tempList = mainList;
            Log.d(TAG, "performFiltering: tempList size " + tempList.size() + ", mainList size " + mainList.size());
            filterResults.count = tempList.size();
            filterResults.values = tempList;

        return filterResults;

    protected void publishResults(CharSequence charSequence, FilterResults filterResults) {
        Log.d(TAG, "publishResults: publishing results...");

        tempList.addAll((List<Product>) filterResults.values);
        Log.d(TAG, "the list size " + tempList.size());

Im using inApp billing service , when I published my project everything was Ok in all devices but there is a problem is some huawei models like p9 lite !!

After debugging , I figured out the problem is in this line:


so I checked the startSetup method codes and finally understood context.bindService always returns False value , so billing service cant start in these phones :(

context.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);

Permisions :

<uses-permission android:name="com.farsitel.bazaar.permission.PAY_THROUGH_BAZAAR" />
<uses-permission android:name="android.permission.INTERNET"/>

Starting IabHelper :

    mHelper = new IabHelper(this,getBazarKey());
    if (checkInstalled()) {
        try {
        } catch (SecurityException e) {
            Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
        Toast.makeText(this, "bazaar is not installed", Toast.LENGTH_SHORT).show();

whats the problem ?

I have my code below thats pull the data from an api using alamofire http request. api used https://jsonplaceholder.typicode.com/posts. i can get all the data but what i want to know is that i want to get all the data but i only what to show in the collection which for example title is equal to this "sunt aut facere repellat provident occaecati excepturi optio reprehenderit" show only title which value is equal to what i have stated above. for example there were a lot of name values but i want only to show whos name: "Dun". Thank You.

Sample Api

    "userId": 1,
    "id": 1,
    "title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
    "body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"

var getAllDetail: [[String:Any]] = [[String:Any]]()

@IBOutlet var collectionView: UICollectionView!
@IBAction func signOutButtonIsPressed(_ sender: Any) {
    let appDelegate : AppDelegate = UIApplication.shared.delegate as! AppDelegate
@IBOutlet var signoutButton: UIButton!
var items = [Item]()

override func viewDidLoad() {

    self.signoutButton.layer.cornerRadius = 3.0

override func viewWillAppear(_ animated: Bool) {

    self.navigationController?.navigationBar.isHidden = true
    self.navigationItem.hidesBackButton =  true


func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
     return getAllDetail.count

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! CollectionCell
    if let getTempDetails: [String : Any] = getAllDetail[indexPath.row] {
        cell.nameLabel.text = getTempDetails["title"] as? String  ?? "" //titleArray[indexPath.row]
    return cell

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {

    // handle tap events
    print("You selected cell #\(indexPath.item)!")
    if let getTempDetails: [String : Any] = getAllDetail[indexPath.row] {
        print("You selected ID #\( getTempDetails["userId"] as? String  ?? "" )!")


func demoApi() {
    Alamofire.request("https://jsonplaceholder.typicode.com/posts", method: .get, parameters: nil, encoding: JSONEncoding.default, headers: nil).responseJSON { (response:DataResponse<Any>) in

        switch(response.result) {
        case .success(_):
            guard let json = response.result.value as! [[String:Any]]? else{ return}
            print("Response \(json)")
            for item in json {


                // if let title = item["title"] as? String {
                //   self.titleArray.append(title)
                // }

            if !self.getAllDetail.isEmpty{
                DispatchQueue.main.async {

        case .failure(_):



After Cambridge Analytica Facebook is now changing its API radically. I was currently working on a Mobile Application using the Scores and Achievements API which is now no longer supported.

I would like to ask for alternatives. I know I could include Game Center but I am not sure if this is the best way since a lot of people dont use the Game Center App any longer. With Facebook I reached a big target Audience since almost everybody is on it and I was able to suggest directly to invite friends for example.

Is it possible to use the Instagram API somehow to store data, like user scores in my example and fetch data or is there a way to achieve similar things with Snapchat that really work well and stable.

Also open minded for other suggestions, which provide similar functions indirecrly or directly like Facebooks past API Thanks for all your help

I have two arrays.



I need to merge these arrays and show it in the dropdown as

c=["91 9989898909","91 9089890890","91 9098979896"].

How can I get this result using swift.Im newbie to swift,can anyone please help on this.

I am a beginner to iOS and I am having a only a lot less knowledge on programming. Now, in my project I got stuck with a task where I have to send the data of a user being created along with the uploading image for camera or from photo library. Actually I don't know how to do that, I have searched the internet, stackoverflow & some other blogs on how to send images with parameters in swift4 and trying to understand the process still and I have been trying this for a week I don't know what else to do. I am posting my code Here:

  @IBAction func createAccountTapped(_sender: UIButton!) {

        let imageData = UIImageJPEGRepresentation(profileImgView.image!, 0.7)
        let base64String = imageData!.base64EncodedString(options: .lineLength64Characters)

        let parameters : Parameters = [
            "UserTypeId": "2",
            "profilePic": base64String,
            "userServices": "",
            "searchAddress": ""

        let updateProfileUrl = "http://isit.beetlerim.com/api/UsersAPI/UpdateUserProfile"

        let image = profileImgView.image

        Alamofire.upload(multipartFormData: {
            multipartFormData in

            if let imageData = UIImageJPEGRepresentation(image!, 0.6) {

                multipartFormData.append(imageData, withName: "profilePic", fileName: "profilepicture.jpg", mimeType: "image/png")

            for (key, value) in parameters {
                multipartFormData.append(((value as Any) as AnyObject).data(using: String.Encoding.utf8.rawValue)!, withName: key)

        }, usingThreshold: UInt64.init() , to: updateProfileUrl, method: .post, headers: ["Content-Type" : "application/json"], encodingCompletion: {
            encodingResult in

            switch encodingResult {
            case .success(let upload, _, _):

                upload.responseJSON {
                    response in
                    print(response.request!)  // original URL request
                    print(response.response!) // URL response
                    print(response.data!)     // server data
                    print(response.result)   // result of response serialization

                    if let JSON = response.result.value {
                        print("JSON: \(JSON)")
            case .failure(let encodingError):

I am getting JSON response.result.value saying : "JSON: { message = "The request entity's media type 'multipart/form-data' is not supported for this resource."; }

I have tried many other ways also.. none of them worked neither.. please help me guys:


In Operations team, a team own licenses of some enterprise products that run through a business process to maintain health of network infrastructure, of customers. These enterprise products belong to NMS domain.

We have written some business process tools(using python REST) that talks to these NMS products, to discover the SNMP devices of our customers.

Daily monitoring is done through interfaces of NMS products. We get production issues from NMS products, amidst this monitoring.

The business process life-cycle is: - To design end-to-end deployment solution(includes NMS products & python tools)

  • Execute the solution

  • Monitor the admin interface of NMS product solution deployed in customer infrastructure

  • Optimise the solution for minimum maintenance

Amidst this life cycle, team embraced Operational acceptance testing(OAT) as main approach. Details of Operational acceptance testing is given here.

Are their testing tools to automate OAT?

Thank you all in advance for the help. This is the first time I am trying to apply design pattern in real life. Specially, I plan to use abstract factory to compose an class called Matrix to achieve the following goals:

  1. The Matrix holds a mutliarray table, and it take info from a visitor object, to retrieve values from the mutliarray, use a few steps to modify the value , and then return the result to the visitor.
  2. There are different "types" of Matrix (not different types in C++ terms). Each type of the Matrix will have different steps to modify the value retrieved from the mutliarray table, before returning the value to the visitor.
  3. Different Matrix have the same user interface with visitor, and should have the same type.

I am trying to achieve the goals using the following approach. Please review and let me know if I am on the right track.

  1. Matrix may hold a Boost multi-array table
  2. Matrix may include a common function T accept_visotr(Visitor&), which will be the common interface of the Matrix.
  3. The accept_visotr() will then indirect the call to the member object called Component_Manager, which will include different steps to retrieve and modify the values.
  4. For each step of modification, I plan to wrap the modification function with a small class, so that the abstract factory can create an object and assign it to the Matrix. For each step, I plan to have a base class, then have subclasses and each subclass would include a different function for the step.

Below is an illustration of the design:

class Mod_1;
class Mod_2;
class Mod_3;
class Mod_4;
class Mod_5;
class Components_Manager;

template <typename T>
class Matrix
    Matrix(int); //construct a Matrix and pass extents to a 3-dimension table

    typedef boost::multi_array<double, 3> array_type;
    typedef array_type::index index;
    array_type Table(boost::extents[int][int][int]);
    std::unique_ptr<Mod_1> mod_1;
    std::unique_ptr<Mod_2> mod_2;
    std::unique_ptr<Mod_3> mod_3;
    std::unique_ptr<Mod_4> mod_4;
    std::unique_ptr<Mod_5> mod_5;
    std::unique_ptr<Components_Manager> component_manager;

    T accept_visotr(Vistor&) 

class Mod_1
  virtual double func_1();

class mod_1_1 : public::Mod_1
    virtual double func_1() override;
class mod_1_2 : public::Mod_1
    virtual double func_1() override;

//other functions similarly defined....

class Component_Manager
    virtual double apply_all_functions(Maxtrix*);

class Component_Manager_1 :public Component_Manager
    virtual double apply_all_functions(Maxtrix* m)

class Component_Manager_2 :public Component_Manager
    virtual double apply_all_functions(Maxtrix* m)