Equalizer  1.6.1
findPipe.h
1 
2 /* Copyright (c) 2010, Stefan Eilemann <eile@eyescale.ch>
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * Redistributions of source code must retain the above copyright notice, this
8  * list of conditions and the following disclaimer. Redistributions in binary
9  * form must reproduce the above copyright notice, this list of conditions and
10  * the following disclaimer in the documentation and/or other materials provided
11  * with the distribution. Neither the name of Eyescale Software GmbH nor the
12  * names of its contributors may be used to endorse or promote products derived
13  * from this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef EQ_ADMIN_FIND_PIPE_H
29 #define EQ_ADMIN_FIND_PIPE_H
30 
31 #include <eq/admin/base.h>
32 
33 namespace eqAdmin
34 {
35 
36 inline eq::admin::Pipe* findPipe( eq::admin::ServerPtr server )
37 {
38  // Find first pipe...
39  const eq::admin::Configs& configs = server->getConfigs();
40  if( configs.empty( ))
41  {
42  std::cout << "No configs on server, exiting" << std::endl;
43  return 0;
44  }
45 
46  eq::admin::Config* config = configs.front();
47  const eq::admin::Nodes& nodes = config->getNodes();
48  if( nodes.empty( ))
49  {
50  std::cout << "No nodes in config, exiting" << std::endl;
51  return 0;
52  }
53 
54  const eq::admin::Node* node = nodes.front();
55  const eq::admin::Pipes& pipes = node->getPipes();
56  if( pipes.empty( ))
57  {
58  std::cout << "No pipes in node, exiting" << std::endl;
59  return 0;
60  }
61 
62  return pipes.front();
63 }
64 
65 }
66 #endif // EQ_ADMIN_FIND_PIPE_H