コード例 #1
0
ファイル: NetStateRule.cs プロジェクト: yuduanopen/MyCaffe
        /// <summary>
        /// Loads a NetStateRule from a binary reader.
        /// </summary>
        /// <param name="br">Specifies the binary reader to use.</param>
        /// <param name="bNewInstance">When <i>true</i>, a new NetStateRule instance is created and loaded, otherwise this instance is loaded.</param>
        /// <returns>The instance of the NetStateRule is returned.</returns>
        public object Load(BinaryReader br, bool bNewInstance)
        {
            NetStateRule p = this;

            if (bNewInstance)
            {
                p = new NetStateRule();
            }

            p.m_phase = (Phase)br.ReadInt32();

            if (br.ReadBoolean())
            {
                p.m_nMinLevel = br.ReadInt32();
            }

            if (br.ReadBoolean())
            {
                p.m_nMaxLevel = br.ReadInt32();
            }

            p.m_rgStage    = Utility.Load <string>(br);
            p.m_rgNotStage = Utility.Load <string>(br);

            return(p);
        }
コード例 #2
0
ファイル: NetStateRule.cs プロジェクト: yuduanopen/MyCaffe
        /// <summary>
        /// Creates a new copy of a NetStateRule instance.
        /// </summary>
        /// <returns>The new instance is returned.</returns>
        public object Clone()
        {
            NetStateRule ns = new NetStateRule();

            ns.m_nMaxLevel  = m_nMaxLevel;
            ns.m_nMinLevel  = m_nMinLevel;
            ns.m_phase      = m_phase;
            ns.m_rgNotStage = Utility.Clone <string>(m_rgNotStage);
            ns.m_rgStage    = Utility.Clone <string>(m_rgStage);

            return(ns);
        }
コード例 #3
0
ファイル: NetStateRule.cs プロジェクト: yuduanopen/MyCaffe
        /// <summary>
        /// Compares this NetStateRule to another one.
        /// </summary>
        /// <param name="obj">Specifies the other NetStateRule to compare.</param>
        /// <returns>0 is returned if the NetStateRule instances match, otherwise 1 is returned.</returns>
        public int CompareTo(object obj)
        {
            NetStateRule nsr = obj as NetStateRule;

            if (nsr == null)
            {
                return(1);
            }

            if (!Compare(nsr))
            {
                return(1);
            }

            return(0);
        }
コード例 #4
0
ファイル: NetStateRule.cs プロジェクト: yuduanopen/MyCaffe
        /// <summary>
        /// Parses a RawProto representing a NetStateRule and creates a new instance of a NetStateRule from it.
        /// </summary>
        /// <param name="rp">Specifies the RawProto used.</param>
        /// <returns>The new NeteStateRule instance is returned.</returns>
        public static NetStateRule FromProto(RawProto rp)
        {
            string       strVal;
            NetStateRule p = new NetStateRule();

            if ((strVal = rp.FindValue("phase")) != null)
            {
                switch (strVal)
                {
                case "TEST":
                    p.phase = Phase.TEST;
                    break;

                case "TRAIN":
                    p.phase = Phase.TRAIN;
                    break;

                case "RUN":
                    p.phase = Phase.RUN;
                    break;

                case "NONE":
                    p.phase = Phase.NONE;
                    break;

                case "ALL":
                    p.phase = Phase.ALL;
                    break;

                default:
                    throw new Exception("Unknown 'phase' value: " + strVal);
                }
            }

            p.min_level = (int?)rp.FindValue("min_level", typeof(int));
            p.max_level = (int?)rp.FindValue("max_level", typeof(int));
            p.stage     = rp.FindArray <string>("stage");
            p.not_stage = rp.FindArray <string>("not_stage");

            return(p);
        }