Beispiel #1
0
        /// <summary>
        /// Save a regular old TObject type values to one of our directories.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="obj"></param>
        /// <param name="dir"></param>
        /// <param name="tag"></param>
        /// <returns></returns>
        public static IFutureValue <T> Save <T>(this T obj, FutureTDirectory dir, string tag = null)
            where T : ROOTNET.Interface.NTObject
        {
            IFutureValue <T> fv = new ImmediateFutureValue <T> {
                Value = obj
            };
            var r = fv.Save(dir, tag);

            return(r);
        }
Beispiel #2
0
 /// <summary>
 /// Helper function to add a future to a directory for later writing.
 /// </summary>
 /// <typeparam name="T">Type of the future value</typeparam>
 /// <param name="dir">Directory where this future value should be saved</param>
 /// <param name="obj">Object to save</param>
 /// <param name="tag">List of tags which can be used to retreive the object later</param>
 public static IFutureValue <T> Save <T>(this IFutureValue <T> obj, FutureTDirectory dir, string tag = null)
     where T : ROOTNET.Interface.NTObject
 {
     if (tag == null)
     {
         dir.AddFuture(obj);
     }
     else
     {
         dir.AddFuture(obj, new string[] { tag });
     }
     return(obj);
 }
Beispiel #3
0
        /// <summary>
        /// Create a new directory
        /// </summary>
        /// <remarks>
        /// In ROOT, when you create a new directory the gDirectory variable isn't changed; so the global directory
        /// will be unchanged by this operation.
        /// </remarks>
        /// <param name="subdirname"></param>
        /// <returns></returns>
        public FutureTDirectory mkdir(string subdirname)
        {
            var rootDir = Directory.mkdir(subdirname);

            if (rootDir == null)
            {
                rootDir = Directory.Get(subdirname) as ROOTNET.Interface.NTDirectory;
                if (rootDir == null)
                {
                    throw new ArgumentException("Unable to create directory '" + subdirname + "' because something with that name already exists in '" + Directory.Name + "'.");
                }
            }
            var future = new FutureTDirectory(rootDir);

            _subDirs.Value.Add(future);

            return(future);
        }
Beispiel #4
0
 /// <summary>
 /// Helper function to write a bunch of values to a directory. NOTE that it returns an enumerable - so you'll
 /// need to loop through it!
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="source"></param>
 /// <param name="dir"></param>
 /// <param name="tag"></param>
 /// <returns></returns>
 public static IEnumerable <IFutureValue <T> > Save <T>(this IEnumerable <IFutureValue <T> > source, FutureTDirectory dir, string tag = null)
     where T : ROOTNET.Interface.NTObject
 {
     foreach (var s in source)
     {
         yield return(s.Save(dir, tag));
     }
 }