• WMS类图结构分析-android12


    为什么要分析类图

    WMS是一个复杂的模块,就像一个很大的家族,里面有各种角色,认识类图就像是认识WMS模块中的各个角色,不先把人认清楚了,怎么更好的理解他们之间的交互?

    我觉得,这也是面向对象的语言魅力,面向对象的语言构建了一个小小的世界,每一个类都是其中的一个角色。

    首先插一张类图,方便后面的分析

    在这里插入图片描述

    具体类图小析

    ConfigurationContainer
    类属性分析

    这是WMS模块中的始祖级别的类,WMS中所有的类都继承于它。

    ConfigurationContainer类中主要有三个Configuration对象,Configuration 本事就是各种基础参数 mode的记录

    mRequestedOverrideConfiguration:当前应用主动请求的Configuration

    mResolvedOverrideConfiguration:mRequestedOverrideConfiguration 经过子类的的调整后的对应容器请求的config,子类会重现相关的方法。

    mFullConfiguration:当前使用的Configuration。

    类方法分析:

    onConfigurationChanged()

    从方法的注释中可以看到,这个方法的作用是当父节点更新后,需要更新自己的全部configuration.

    public abstract class ConfigurationContainer<E extends ConfigurationContainer> {
        
        //下面三个Configuration对象是配置相关的基础对象,onfiguration对象本身主要是一些参数的配置。
        /**
         * Contains requested override configuration settings applied to this configuration container. 当前应用主动请求的所有config
         */
        private Configuration mRequestedOverrideConfiguration = new Configuration();
        
         /**
         * Contains the requested override configuration with parent and policy constraints applied.
         * This is the set of overrides that gets applied to the full and merged configurations.为mRequestedOverrideConfiguration 经过子类的的调整后的对应容器请求的config
         */
        private Configuration mResolvedOverrideConfiguration = new Configuration();
        
         /**
         * Contains full configuration applied to this configuration container. Corresponds to full
         * parent's config with applied {@link #mResolvedOverrideConfiguration}.为父亲的config(mFullConfiguration) 加上自己的mResolvedOverrideConfiguration 组合成自身的mResolvedOverrideConfiguration
         */
        private Configuration mFullConfiguration = new Configuration();//这个是返回的configuration
        
         /**
         * Returns full configuration applied to this configuration container.
         * This method should be used for getting settings applied in each particular level of the
         * hierarchy.从getConfiguration函数中可以看出,mFullConfiguration是在使用的congfiguration
         */
        public Configuration getConfiguration() {
            return mFullConfiguration;
        }
        
        //onConfigurationChanged 当配置发生改变时调用,会在onParentChanged中调用
        public void onConfigurationChanged(Configuration newParentConfig) {
            mResolvedTmpConfig.setTo(mResolvedOverrideConfiguration); //先保存mResolvedOverrideConfiguration
            resolveOverrideConfiguration(newParentConfig);//mResolvedOverrideConfiguration从newParentConfig中算出来
            mFullConfiguration.setTo(newParentConfig);//mFullConfiguration 设为 newParentConfig
            mFullConfiguration.updateFrom(mResolvedOverrideConfiguration);//重新计算mFullConfiguration
            onMergedOverrideConfigurationChanged();
            if (!mResolvedTmpConfig.equals(mResolvedOverrideConfiguration)) {
                // This depends on the assumption that change-listeners don't do
                // their own override resolution. This way, dependent hierarchies
                // can stay properly synced-up with a primary hierarchy's constraints.
                // Since the hierarchies will be merged, this whole thing will go away
                // before the assumption will be broken.
                // Inform listeners of the change.
                for (int i = mChangeListeners.size() - 1; i >= 0; --i) {
                    mChangeListeners.get(i).onRequestedOverrideConfigurationChanged(
                            mResolvedOverrideConfiguration);//通知子节点更新
                }
            }
            for (int i = mChangeListeners.size() - 1; i >= 0; --i) {
                mChangeListeners.get(i).onMergedOverrideConfigurationChanged(
                        mMergedOverrideConfiguration);
            }
            for (int i = getChildCount() - 1; i >= 0; --i) {
                dispatchConfigurationToChild(getChildAt(i), mFullConfiguration);
            }
        }
        
        //应该是parent发生变化是被调用
        void onParentChanged(ConfigurationContainer newParent, ConfigurationContainer oldParent) {
            // Removing parent usually means that we've detached this entity to destroy it or to attach
            // to another parent. In both cases we don't need to update the configuration now.
            if (newParent != null) {
                // Update full configuration of this container and all its children.
                onConfigurationChanged(newParent.mFullConfiguration);
                // Update merged override configuration of this container and all its children.
                onMergedOverrideConfigurationChanged();
            }
        }
    }
     and all its children.
                onMergedOverrideConfigurationChanged();
            }
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
  • 相关阅读:
    XSS & CSRF
    王者荣耀改名神器助手微信小程序
    Pro Git日常学习记录-Git基础-10.Git别名
    巧用 API 网关构建大型应用体系架构
    Apollo自动驾驶平台:从传感器到决策的技术解析
    高性能计算与多模态处理的探索之旅:英伟达GH200性能优化与GPT-4V的算力加速未来
    XSS进阶二
    MySQL:远程连接数据库(2)
    参数估计(点估计和区间估计)
    多模态论文阅读-LLaVA
  • 原文地址:https://blog.csdn.net/weixin_42376458/article/details/128072630